我的第一个视图控制器上有一个无限旋转的图像作为背景,效果很好!
@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))
}
(来源:https://github.com/vin20777/infinite-rotate-animation)
当用户在应用程序的各个视图控制器中移动时,是否有可能使旋转继续在后台可见并且在后台不间断?如果是这样,怎么做?
谢谢您的帮助!