我正在尝试根据用户的当前路线在我的应用程序中旋转地图视图。(我不喜欢使用内置罗盘,因为只有 3GS 使用它,并且受到其他机器(即您自己的汽车)的干扰太大。)。
CGAffineTransformMakeRotation 方法将旋转整个地图视图,因此 Google 徽标将不再位于屏幕的右下方。此外,所有注释视图都会旋转并且在应用程序上看起来很奇怪。
有谁知道如何只旋转 MkMapView 的内容(街道 drwaings)?
谢谢
这是我旋转 MapView 的方式(请参阅使用指南针方向旋转 MapView):
[self.mapView setTransform:CGAffineTransformMakeRotation(-1 * currentHeading.magneticHeading * 3.14159 / 180)];
然后将注释视图的方向与设备顶部保持一致:
for (MKAnnotation *annotation in self.mapView.annotations) {
MKAnnotationView *annotationView = [self.mapView viewForAnnotation:annotation];
[annotationView setTransform:CGAffineTransformMakeRotation(currentHeading.magneticHeading * 3.14159 / 180)];
}
如果您希望 annotationViews 的旋转点位于底部中心,我相信您会按如下方式设置每个视图的 anchorPoint:
annotationView.layer.anchorPoint = CGPointMake(0.5, 1.0);
但是,当我这样做时,annotationView 位置更改仍然存在一些问题(可能与 stackoverflow 问题相同的问题:changeing-my-calayers-anchorpoint-moves-the-view)。