Ich versuche, meinen zwei MKPointAnnotation-Pins ein benutzerdefiniertes Bild zu geben. Bis jetzt bin ich in der Lage, das gleiche Bild auf beiden Stiften anzuzeigen. Was kann ich mit dem unten stehenden Code tun, um jedem Pin ein benutzerdefiniertes Image zu geben?Mehrere benutzerdefinierte Punkt-Anmerkungen - Swift
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
}
Aber wie greife ich auf die examplePoint = MKPointAnnotation() Bild? – cosmos