3

I have This code here including userTrackingMode = .follow and it works great but it just pops onto Userlocation instead of animating the map to go to the user location ...which is what i want . Anyone can tell me hot to add that animation making the map change onto the user location by animation and not just pop onto it ( if it makes sense )

import UIKit
import MapKit
import CoreLocation

class MapViewController: UIViewController,MKMapViewDelegate, CLLocationManagerDelegate{

    @IBOutlet weak var mapView: MKMapView!

    @IBAction func UserTrackingMode(sender: AnyObject) {

        mapView.userTrackingMode = .Follow
    }
Newbie Questions
  • 463
  • 1
  • 11
  • 31
adirbuilder
  • 101
  • 1
  • 12
  • https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapView_Class/#//apple_ref/occ/instm/MKMapView/setUserTrackingMode:animated: – Paulw11 Sep 02 '16 at 00:08

1 Answers1

2

You can call setUserTrackingMode:animated in order to animate the transition:

@IBAction func UserTrackingMode(sender: AnyObject) {

    mapView.setUserTrackingMode(.Follow, animated:true)
}
Paulw11
  • 108,386
  • 14
  • 159
  • 186