我想給我的兩個MKPointAnnotation針自定義圖像。到目前爲止,我可以在兩個引腳上顯示相同的圖像。我可以對下面的代碼做些什麼來給每個pin一個自定義圖像?多個自定義點註釋 - 斯威夫特
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard !(annotation is MKUserLocation) else {
return nil
}
let annotationIdentifier = "AnnotationIdentifier"
var annotationView: MKAnnotationView?
if let dequeuedAnnotationView = mapView.dequeueReusableAnnotationView(withIdentifier: annotationIdentifier) {
annotationView = dequeuedAnnotationView
annotationView?.annotation = annotation
}
else {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
}
if let annotationView = annotationView {
annotationView.canShowCallout = true
annotationView.image = UIImage(named: "Moto_pin")
}
return annotationView
}
但是我怎麼訪問examplePoint = MKPointAnnotation()形象? – cosmos