我目前正在使用MapKit进行一些开发,我有它,所以如果你点击地图,MKCirle会在屏幕上呈现。圆圈的中心是您的拍子位置,我有一个预定义的半径。我想给它一个雷达动画,它以零半径开始,并在点击时扩展到我的给定半径。我的代码如下,任何想法或解决方案?
这是初始化
let touch = gesture.location(in: mapView)
touchCoordinate = mapView.convert(touch, toCoordinateFrom: mapView)
let touchLocation = CLLocation(latitude: touchCoordinate.latitude, longitude: touchCoordinate.longitude)
let radius: Double = 200
let region = CLCircularRegion(center: touchCoordinate, radius: radius, identifier: "Tap")
self.locationManager.startMonitoring(for: region)
mapView.removeOverlays(mapView.overlays)
let circle = MKCircle(center: region.center, radius: region.radius)
self.mapView.add(circle)
这里是渲染函数
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
if overlay is MKCircle{
let renderer = MKCircleRenderer(overlay: overlay)
renderer.strokeColor = .blue
renderer.alpha = 1
renderer.lineWidth = 2
return renderer
}
return MKOverlayRenderer()
}