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

Latest commit

 

History

History
48 lines (33 loc) · 1.03 KB

README.md

File metadata and controls

48 lines (33 loc) · 1.03 KB

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