When MKMarkerAnnotationView
is used for annotation, the title is shown under the icon, how to do it in MKAnnotationView
?
Example:
title show in under icon:
annotationView = MKMarkerAnnotationView(annotation: nil, reuseIdentifier: identifier)
title not show in under icon:
annotationView = MKAnnotationView(annotation: nil, reuseIdentifier: identifier)
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard annotation is MKPointAnnotation else { return nil }
let identifier = "Annotation"
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier)
if annotationView == nil {
annotationView = MKMarkerAnnotationView(annotation: nil, reuseIdentifier: identifier)
annotationView!.isEnabled = true
annotationView!.canShowCallout = true
annotationView!.annotation = annotation
annotationView!.displayPriority = .required
} else {
annotationView!.annotation = annotation
}