我正在尝试在完整的 map 空间上添加 ovarlay。我尝试使用
@available(iOS 4.0, *)public let MKMapRectWorld: MKMapRect
但我找不到正确的方法。
最佳答案
我已经找到办法了。
将叠加层添加到 map View ,例如 viewDidLoad:
if let fullRadius = CLLocationDistance(exactly: MKMapRectWorld.size.height) {
mapView.add(MKCircle(center: mapView.centerCoordinate, radius: fullRadius))
}
并实现委托(delegate)方法:
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
if overlay.isKind(of: MKCircle.self) {
let view = MKCircleRenderer(overlay: overlay)
view.fillColor = UIColor.blue.withAlphaComponent(0.1)
return view
}
return MKOverlayRenderer(overlay: overlay)
}
关于ios - 如何在整个世界地图 iOS Swift 上向 MKMapView 添加叠加层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42694619/