我正在尝试根据用户的当前路线在我的应用中旋转地图视图。 (我不喜欢使用内置的compasse,因为只有3GS使用它并且它受到来自其他机器(即你自己的汽车)的太多干扰。)。
CGAffineTransformMakeRotation方法将旋转整个地图视图,因此Google徽标将不再位于屏幕的右下方。此外,所有注释视图都将在App上旋转并显得奇怪。
有谁知道如何旋转MkMapView的内容(街道drwaings)?
由于
答案 0 :(得分:2)
以下是我如何旋转MapView(参见Rotate MapView using Compass orientation):
[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问题相同:changing-my-calayers-anchorpoint-moves-the-view)。