如何减慢 Swift 中的 MapView 动画?
How to slow down MapView animation in Swift?
我有一行 Swift 将地图的中心设置为点击的注释。
mapView.setCenter(annotation.coordinate, animated: true)
不过这个动画太快了。有没有办法让它慢下来?
您不需要在 UIView
动画函数中调用 setCenter(_:animated:)
, at this point. What you could do is to directly set a value for centerCoordinate
:
// set your needed time per second, the current is 3.0 seconds
UIView.animate(withDuration: 3.0) {
self.mapView.centerCoordinate = annotation.coordinate
}
我有一行 Swift 将地图的中心设置为点击的注释。
mapView.setCenter(annotation.coordinate, animated: true)
不过这个动画太快了。有没有办法让它慢下来?
您不需要在 UIView
动画函数中调用 setCenter(_:animated:)
, at this point. What you could do is to directly set a value for centerCoordinate
:
// set your needed time per second, the current is 3.0 seconds
UIView.animate(withDuration: 3.0) {
self.mapView.centerCoordinate = annotation.coordinate
}