2017-07-27 50 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中修復。我們只好等。