在iOS11 beta 4上绘制折线问题?
问题描述:
我在绘制多段线时遇到了麻烦,我想我已经推断它是iOS 11 beta 4的一个问题。昨天它使用相同的代码工作,现在我已更新到beta 4,不要画多段线。在iOS11 beta 4上绘制折线问题?
刚刚在iOS 10.3模拟器上的Xcode 8以及iOS 11b4模拟器上的Xcode 9b4中进行了验证。
代码:
import MapKit
class ViewController: UIViewController, MKMapViewDelegate {
let mapView = MKMapView()
override func viewDidLoad() {
super.viewDidLoad()
mapView.frame = CGRect(x: 10, y: 10, width: 300, height: 300)
mapView.delegate = self
mapView.region = MKCoordinateRegionMake(CLLocationCoordinate2D(latitude: 51.482736, longitude: -0.015253), MKCoordinateSpanMake(0.005, 0.005))
mapView.delegate = self
let coordinate1 = CLLocationCoordinate2D(latitude: 51.482736, longitude: -0.015253)
let coordinate2 = CLLocationCoordinate2D(latitude: 51.482736, longitude: -0.016253)
let polyline = MKPolyline(coordinates: [coordinate1, coordinate2], count: 2)
mapView.add(polyline, level: .aboveLabels)
view.addSubview(mapView)
}
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let renderer = MKPolylineRenderer(overlay: overlay)
renderer.strokeColor = UIColor.red
renderer.lineWidth = 4.0
return renderer
}
}
注解添加到地图中没有问题。
答
在beta 5中修复。我们只好等。
我遇到同样的问题。我们可以做什么来使它在ios11中显示? – davidk
等待测试5 – Andrew
在我的代码中,似乎最初没有显示折线。但是,在放大/缩小地图后,它会出现。 – davidk