Created
December 29, 2014 15:52
-
-
Save alexruperez/fcd0f523f14cdc5915d1 to your computer and use it in GitHub Desktop.
MKMapView extension with setVisibleMapAnnotations edgePadding animated helper in Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension MKMapView | |
{ | |
func setVisibleMapAnnotations(edgePadding: UIEdgeInsets, animated: Bool) | |
{ | |
var zoomRect = MKMapRectNull | |
for annotationObject in annotations | |
{ | |
let annotation = annotationObject as MKAnnotation | |
let annotationPoint = MKMapPointForCoordinate(annotation.coordinate) | |
let pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0.1, 0.1) | |
if (MKMapRectIsNull(zoomRect)) | |
{ | |
zoomRect = pointRect | |
} | |
else | |
{ | |
zoomRect = MKMapRectUnion(zoomRect, pointRect) | |
} | |
} | |
setVisibleMapRect(zoomRect, edgePadding: edgePadding, animated: animated) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment