Change the image's origin of map annotation view?

房东的猫 提交于 2019-12-04 04:28:55

MKAnnotationView has a centerOffset property which you can try setting to adjust the image offset:

customPinView.centerOffset = CGPointMake(xOffset,yOffset);


Unrelated, but you should use initWithAnnotation instead of just init for creating an MKAnnotationView.
It also wouldn't hurt to use dequeueReusableAnnotationViewWithIdentifier and implement annotation view re-use to improve performance.

I would also suggest not programmatically resizing the image in the delegate method and instead using an already-resized image to begin with. Then you can just do customPinView.image = [UIImage imageNamed:@"resizedWaterPin.png"]; without spending run-time resizing the annotation images every time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!