我在 MKMapView 中使用 MKPolyline 在位置之间绘制直线
let locations:[CLLocationCoordinate2D] = ...
let polyLine = MKPolyline(coordinates: locations, count: locations.count)
mapView.add(polyLine)
// MKMapViewDelegate
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let renderer = MKPolylineRenderer(overlay: overlay)
renderer.strokeColor = UIColor.red
renderer.lineWidth = 4.0
return renderer
}
现在我想显示从一个坐标到另一个坐标的线的绘制动画,而不是已经画好的线。有没有可能这样做?任何想法将不胜感激。
最佳答案
从你的坐标数组中,在第一项和第二项之间画一条折线,比如在 0.1 秒内,然后用第一项绘制到第三项,依此类推,直到用计时器从第一项绘制到最后一项,你可以有从源到目的地的动画绘制
关于ios - MK map View : Animate Drawing of MKPolyline Between Locations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48557371/