Мне нужна аннотация с другим цветом по значению из Firebase, поэтому я создал класс:
class AnnotationClass : MKPointAnnotation {
var parametro: String?
var titolo:String?
var sottotitolo: String?
var tipo: String?
}
, а затем установил его:
let annotation = AnnotationClass()
annotation.titolo = location.citta?.uppercased() as? String
annotation.sottotitolo = "\(location.titolo!) POSTI"
annotation.parametro = "\(location.id!)"
annotation.tipo = "\(location.tipo!)"
annotation.title = "\(location.tipo!)"
простое здесь, как его получитьв следующей функции?if annotationView? .annotation? .tipo == "CONCORSO" ОШИБКА: значение типа 'MKAnnotation' не имеет члена 'tipo'
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
var annotationView: MKMarkerAnnotationView? = mapView.dequeueReusableAnnotationView(withIdentifier: "mia2") as? MKMarkerAnnotationView
annotationView = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: "mia2")
if annotationView?.annotation?.tipo == "CONCORSO" {
annotationView?.markerTintColor = #colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1)
annotationView?.glyphText = "C"
} else {
annotationView?.markerTintColor = #colorLiteral(red: 0.9254901961, green: 0.2352941176, blue: 0.1019607843, alpha: 1)
annotationView?.glyphText = "A"
}
return annotationView
}