【发布时间】:2018-04-10 08:24:31
【问题描述】:
我无法在用户当前位置放置“常规”图钉。我四处寻找,但找不到太多。现在,在用户的当前位置,我只有位置信标。我怎样才能把它改成普通的“别针”?我试过 nnotationView?.annotation = annotation 但这似乎不起作用。
extension ViewController: MKMapViewDelegate {
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "AnnotationView")
if annotationView == nil {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "AnnotationView")
}
if let title = annotation.title, title == "Park Test" {
annotationView?.image = UIImage(named: "Park icon test")
}
else if annotation === mapView.userLocation {
return nil
}
annotationView?.canShowCallout = true
return annotationView
}
【问题讨论】:
标签: swift annotations mkannotationview mkmapviewdelegate