Mkmapview 如何设置MKAnnotationView的旋转中心

Mkmapview 如何设置MKAnnotationView的旋转中心,mkmapview,mkannotationview,mkpinannotationview,Mkmapview,Mkannotationview,Mkpinannotationview,当在MKMapView上启用MKUserTrackingModeFollowWithHeading时,我的MKAnnotationViews出现问题 我使用MKAnnotationView的centerOffset属性定位了图像。指定针尖相对于图像中心坐标系的坐标有些反直觉,但我提出了以下公式: annotationView.centerOffset = CGPointMake(imageWidth/2.0 - tipXCoordinate, imageHeight/2.0 - tipYCord

当在MKMapView上启用
MKUserTrackingModeFollowWithHeading
时,我的
MKAnnotationView
s出现问题

我使用MKAnnotationView的centerOffset属性定位了图像。指定针尖相对于图像中心坐标系的坐标有些反直觉,但我提出了以下公式:

annotationView.centerOffset = CGPointMake(imageWidth/2.0 - tipXCoordinate, imageHeight/2.0 - tipYCordinate);
这适用于放大和缩小地图。大头针的尖端在地图上保持相对位置

但是,当我启用
MKUserTrackingModeFollowWithHeading
时,它将不再工作。针围绕图像的中心旋转,而不是尖端。因此,当地图旋转时,提示不会指向它们应该注释的位置

我对
MKAnnotationView
框架
中心
属性进行了一些研究,但我觉得它们对管脚的对齐没有任何影响

有趣的是,
MKPinAnnotationView
似乎根本不使用
centerOffset
,而是使用移位的
帧。然而,我无法复制这一点。更改自定义视图的
,根本不会移动它

感谢您提供的任何见解:-)

解决方案:

不要使用中心偏移!改用
annotationView.layer.anchorPoint
。achor点的坐标系也更好。图像矩形的坐标范围为0.0(上/左)到1.0(下/右):

annotationView.layer.anchorPoint = CGPointMake(tipXCoordinate/imageWidth, tipYCordinate/imageHeight);

一位朋友让我告诉你,你应该“试试这个例子”:

告诉你的朋友,他是我本周的个人英雄:-)非常感谢!
self.layer.anchorPoint = CGPointMake (0.5f, 1.0f);