1
我想旋轉MKAnnotation圖像,雖然我成功這樣做,它的標題也旋轉。有沒有辦法讓標題保持直線?任何幫助將非常感激!旋轉mkannotation圖像不是標題
這裏是我的代碼:
在viewDidLoad中()...
let middlePoint = CustomPointAnnotation()
middlePoint.coordinate = self.coordinates
middlePoint.imageName = "routemiddle"
middlePoint.title = "\(hourDetailedRoute):\(minuteDetailedRoute)"
middlePoint.courseDegrees = self.vehicleChangeCourse
self.mapa.addAnnotation(middlePoint)
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if !(annotation is CustomPointAnnotation) {
return nil
}
let reuseId = "annotation"
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if anView == nil {
anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
anView!.canShowCallout = true
}
else {
anView!.annotation = annotation
}
let cpa = annotation as! CustomPointAnnotation
anView!.image = UIImage(named:cpa.imageName)
anView!.transform = CGAffineTransformRotate(self.mapa.transform, CGFloat(degreesToRadians(cpa.courseDegrees)))
return anView
}
類CustomPointAnnotation:MKPointAnnotation {
var imageName: String!
var courseDegrees = 0.0
}