Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

serejahh/MKMapView-Reusable

Repository files navigation

MKMapView+Reusable

Reuse MKAnnotationView as easy as UITableViewCell/UICollectionViewCell.

Usage

Vanilla

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
}

With Reusable

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
    let annotationView = mapView.dequeueReusableAnnotationView(annotation) as PassAnnotationView
    
    // configure the annotation view 
        
    return annotationView
}

Installation

Cocoapods

pod 'MKMapView-Reusable', '~> 1.0'

Carthage

github `serejahh/MKMapView-Reusable` ~> 1.0

About

[Deprecated] Reuse MKAnnotationView as easy as UITableViewCell/UICollectionViewCell

Resources

License

Stars

Watchers

Forks