2017-07-27 49 views
2

我在绘制多段线时遇到了麻烦,我想我已经推断它是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 
    } 
} 

iOS的10: enter image description here

iOS的11: enter image description here

注解添加到地图中没有问题。

+1

我遇到同样的问题。我们可以做什么来使它在ios11中显示? – davidk

+0

等待测试5 – Andrew

+2

在我的代码中,似乎最初没有显示折线。但是,在放大/缩小地图后,它会出现。 – davidk

回答

1

在beta 5中修复。我们只好等。