Last active
March 21, 2016 00:06
-
-
Save KyleGoslan/f0894fba0a7685516d0e to your computer and use it in GitHub Desktop.
Animate MKMapCamera in Swift 2
This file contains 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
//Create a new MKMapCamera object. | |
//Looking at, is where you want it to look at, in this example I keep it the same so use the map views current center coordinate | |
//I up the altitude (zoom out) by adding 1600 on to the current position | |
//Pitch and heading are the rotation and angle of the camera | |
let newCameraPosition = MKMapCamera(lookingAtCenterCoordinate: mapView.centerCoordinate, fromDistance: mapView.camera.altitude + 1600, pitch: 50, heading: -30) | |
//Animate the camera, here over 5 seconds with a 1.5 second delay, the options are fairly self explanitory. | |
UIView.animateWithDuration(5, delay: 1.5, options: [.AllowUserInteraction, .CurveEaseInOut], animations: { | |
self.mapView.camera = newCameraPosition | |
}) { success in | |
//Animation completed... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment