开发者

MKPinAnnotationView image offset?

开发者 https://www.devze.com 2023-02-06 06:22 出处:网络
Does anyone have any idea why images used for a MKPinAnnotationView should be offset slightly (up and to the right) the code I am using is:

Does anyone have any idea why images used for a MKPinAnnotationView should be offset slightly (up and to the right) the code I am using is:

pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinView_ID];
pinView.image = [UIImage imageNamed: @"TEST_Small.png"];
// RedCircleImage = 40px x 40px 72dpi PNG
// GreenDotImage = 2px x 2px 72dpi PNG

MKPinAnnotationView image offset?

There are no changes to the code just a change in the filename for the image used, one image is the "the two red rings with a black dot in the center" the other is the "small green dot" I have added the thin blue lines in Photoshop to help show where 开发者_如何学JAVAthe green dot is.

I have checked the centerOffset property and its correctly set to 0,0

Any ideas would be welcome.


As Dolbz has pointed out, you should use MKAnnotationView instead of MKPinAnnotationView. When you set the image, you can also set a centerOffset that is appropriate for your image. The default centerOffset should work for your images, but if you would display a pin, flag, etc. you would set it differently.

0

精彩评论

暂无评论...
验证码 换一张
取 消