I have requirement like on my current location one view will display. It will rotate if device was rotate or location will be change.I research lot but got all the code whic
Try this, it worked for me
func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading:CLHeading) {
UIView.animate(withDuration: 0.005) {
let angle = newHeading.trueHeading.toRadians() // convert from degrees to radians
self.yourImageHere.transform = CGAffineTransform(rotationAngle: CGFloat(angle)) // rotate the picture
}
}
override func viewDidLoad() {
super.viewDidLoad()
locationManager.startUpdatingHeading()
}