Convert MKMapPoint to NSValue in Swift

前端 未结 3 1883
星月不相逢
星月不相逢 2021-01-19 08:22

I want to convert an MKMapPoint to a NSValue. In Objective-C i can do it with the following statement:

MKMapPoint point = MKMapPointForCoordinate(location.co         


        
3条回答
  •  星月不相逢
    2021-01-19 09:04

    I think Leo's answer isn't correct anymore, I managed to convert array of MKMapPoint to an array of CGPoint with the code below :

    let polygonView = MKPolygonRenderer(overlay: overlay)
    let polyPoints = polygonView.polygon.points() //returns [MKMapPoint]
    var arrOfCGPoints : [CGPoint] = []
    for i in 0..

    And to NSValue :

    ler someCgPoint = arrOfCGPoints[0]
    var pointObj = NSValue(CGPoint: someCgPoint)
    

提交回复
热议问题