I've got an infinitely rotating image as the background on my first view controller and it works so good!
@IBOutlet var background: UIImageView!
func rotate1(imageView: UIImageView, aCircleTime: Double) {
let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation")
rotationAnimation.fromValue = 0.0
rotationAnimation.toValue = -Double.pi * 2
rotationAnimation.speed = 0.1
rotationAnimation.duration = aCircleTime
rotationAnimation.repeatCount = .infinity
imageView.layer.add(rotationAnimation, forKey: nil)
}
override func viewWillAppear(_ animated: Bool) {
rotate1(imageView: background, aCircleTime: Double.pi)
background.transform = background.transform.rotated(by: CGFloat(Double.pi))
}
(Source: https://github.com/vin20777/infinite-rotate-animation)
Is it possible to have this rotation continue visible and uninterrupted in the background as the user moves through the various view controllers of the app? If so, how is it done?
Thank you for any help!