xcode - Swift4 中所有视图控制器的连续背景动画
问题描述
我的第一个视图控制器上有一个无限旋转的图像作为背景,效果很好!
@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 )
当用户在应用程序的各种视图控制器中移动时,是否可以让这种旋转在后台继续可见且不间断?如果是这样,它是如何完成的?
感谢您的任何帮助!
解决方案
推荐阅读
- objective-c - Objective-C and Swift interoperability inside framework with module mapping
- python - Telethon:我可以在 iter_message 中使用两个过滤器吗?
- javascript - Javascript 在 HTML 但不是 XHTML JSF 中工作
- nrwl-nx - 将 nx 更新到 9.2.4 失败:不兼容更漂亮
- microservices - 如何在没有 docker 的情况下实现滚动发布更新/回滚?
- python - 如何在 python 中修复此错误“列表超出范围”?
- css - Angular 9 - 在 CSS 中使用 :host 与 !important 来覆盖子类中的 CSS 属性
- pivot-table - Clickhouse 中的 Pivot 或等效项
- php - Laravel : Illuminate\Auth\AuthManager::$isAdmin
- webpack - 如何在构建文件夹中使用 index.html 构建 webpack 项目,并在另一个文件夹中构建所有依赖项?