我想给我的两个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