如何在MapKit中在圆心和边框之间画一条线?

时间:2019-06-26 22:03:19

标签: ios swift mapkit

我使用MapKit在地图上绘制了圆,但是现在我不知道如何在圆心和边界之间画一条线。谁能告诉我该怎么做?

代码:

class MainViewController: UIViewController {

@IBOutlet private weak var mapView: MKMapView!


// MARK: - life cycle

override func viewDidLoad() {
    super.viewDidLoad()

    setupUI()
}


// MARK: - private

private func setupUI() {
    mapView.delegate = self
    let circle = MKCircle(center: location, radius: 10000 as CLLocationDistance)
    mapView.addOverlay(circle)
}


extension MainViewController: MKMapViewDelegate {
    func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
        let circle = MKCircleRenderer(overlay: overlay)
            circle.strokeColor = UIColor.red
            circle.fillColor = UIColor(red: 255, green: 0, blue: 0, alpha: 0.1)
            circle.lineWidth = 1
            return circle
    }
}

我需要这样的东西:

enter image description here

0 个答案:

没有答案