如何在MKMapView上为anotations的移动设置动画

Oks*_*ana 4 iphone sdk xcode objective-c

如何在MKMapView上设置注释的移动动画?当注释的位置发生变化时,注释会移动到带动画的其他位置吗?

Pav*_*eev 14

这个问题有答案.

简单地在UIView animateWithDuration中包装坐标更改似乎工作正常:

[UIView animateWithDuration:0.3f
                 animations:^{
    myAnnotation.coordinate = newCoordinate;
}]
Run Code Online (Sandbox Code Playgroud)


Sri*_*aju -3

您需要使用这些委托方法setRegion:animated:&regionThatFits:

[mapView setRegion:region animated:YES];
[mapView regionThatFits:region];
Run Code Online (Sandbox Code Playgroud)

另请注意,使用模拟器时地图更新不适用于动画。当您尝试setCenterCoordinate:animated:使用该设备时,它确实可以使用动画。