Reuse MKAnnotationView as easy as UITableViewCell/UICollectionViewCell.
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
let annotationView: PassAnnotationView
if let view = dequeueReusableAnnotationViewWithIdentifier(annotationViewType.reuseIdentifier) as? T {
annotationView = view
} else {
return PassAnnotationView(annotation: annotation, reuseIdentifier: "annotation")
}
// configure the annotation view
return annotationView
}
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
let annotationView = mapView.dequeueReusableAnnotationView(annotation) as PassAnnotationView
// configure the annotation view
return annotationView
}
pod 'MKMapView-Reusable', '~> 1.0'
github `serejahh/MKMapView-Reusable` ~> 1.0