User Tracking Mode Missing Animation, Swift

1k Views Asked by At

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
    }
1

There are 1 best solutions below

0
On BEST ANSWER

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

@IBAction func UserTrackingMode(sender: AnyObject) {

    mapView.setUserTrackingMode(.Follow, animated:true)
}