我有一个应用程序,它具有汽车的原始方位,但是当我倾斜或旋转 map 时,它会跟随,我不想要这种行为。我想要一些注释 View 不随 map 倾斜或旋转的行为。
在谷歌地图中,您只需将其设置为 false Flat or Billboard orientation
MKAnnotationView
或 MKPinAnnotationView
中是否有相同的示例?
最佳答案
您可以通过反转注释上的旋转角度来实现此目的:
func mapViewDidChangeVisibleRegion(_ mapView: MKMapView) {
for annotation: MKAnnotation? in mapView.annotations {
var annotationView: MKAnnotationView?
if let anAnnotation = annotation {
annotationView = mapView.view(for: anAnnotation)
}
let headingInRadians = mapView.camera.heading * Double.pi / 180
annotationView?.transform = CGAffineTransform(rotationAngle: -headingInRadians)
}
}
关于ios - 本地图旋转或倾斜时禁用 mkannotationview 的旋转 - swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41746248/