my problem is that annotationView.image = X doesn't work, I just can't see the special pin, just purple(pinTintColor) if I remove it - it becomes red..
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
for mall in malls {
let coords = CLLocation(latitude: mall.latitude, longitude: mall.longitude)
let annotation = MyAnnotation.init(coordinate: coords.coordinate, mall: mall, title: mall.name, subtitle: mall.adress)
self.mapView.addAnnotation(annotation)
}
}
and also i can't add image as accessoryview. What's the problem?
extension commonMapViewController: MKMapViewDelegate {
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard !(annotation is MKUserLocation) else {return nil }
let annotationIdentifier = "restAnnotation"
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: annotationIdentifier) as? MKPinAnnotationView
if annotationView == nil {
annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
annotationView?.rightCalloutAccessoryView = rightImage
annotationView?.canShowCallout = true
}
annotationView?.pinTintColor = #colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)
annotationView?.image = UIImage(named: "malls.png")
return annotationView
}
Thanks for your help and excuse me for my stupidness..