MKMapView'dan türetilmiş bir özel sınıf oluşturmanız gerekir. Bu sınıf, MKMapViewDelegate
protokolünü uygulamak zorundadır.
Sonra 2 adıma ihtiyacınız vardır: Ek açıklama nesnesini oluşturun ve bu açıklama için bir görünüm oluşturun.
Not Oluştur: Somewhere kodunuzu
, ihtiyaçlarınıza bağlıdır:
let annotation = MKPointAnnotation()
annotation.setCoordinate(location) // your location here
annotation.title = "My Title"
annotation.subtitle = "My Subtitle"
self.mapView.addAnnotation(annotation)
açıklama Görünüm
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if annotation is MKPointAnnotation {
let pinAnnotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "myPin")
pinAnnotationView.pinColor = .Purple
pinAnnotationView.draggable = true
pinAnnotationView.canShowCallout = true
pinAnnotationView.animatesDrop = true
return pinAnnotationView
}
return nil
}
Çok teşekkürler! : D –