我遇到了在swift 3中显示Overlay的问题。更新已经完成并且我似乎无法显示它:在我的视图中确实加载
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
mapView.delegate = self
setup()
//on tap creates annotation with reverse geocoded address
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(ViewController.addAnnotation))
mapView.addGestureRecognizer(tapGesture)
let coordinates = CLLocationCoordinate2D(latitude: 37.78494283, longitude: -122.39712273)
let region = CLCircularRegion(center: coordinates, radius: 1000, identifier: "Folsem Office")
self.mapView.add(MKCircle(center: coordinates, radius: 500))
region.notifyOnEntry = true
region.notifyOnExit = true
}
在我的委托方法中:
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
if let circle = overlay as? MKCircle {
let renderer = MKOverlayRenderer.init(overlay: circle)
return renderer
}
return MKOverlayRenderer()
}
发布的答案https://stackoverflow.com/a/33293217/5988899似乎对我不起作用
答案 0 :(得分:1)
将MKOverlayRenderer.init()
替换为MKCircleRenderer()