我们有动画(大约 6-7 秒,700x700 像素,透明背景),由一家设计公司准备。
我需要在我们的 iOS 应用程序的开头展示这些作为介绍。< br/>
在应用程序中轻松使用它们的最佳方式/格式是什么?
我不想处理动画细节,因为它们都是设计师已经准备好的。
到目前为止,我们尝试了使用 UIView
的 animationImages
功能的 png 序列,但这种方法对内存不友好。
你有什么建议?
最佳答案
试试这个简单的方法:
let timer = Timer()
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// I am using tiff image file for animation.You can use png or jpg both will works...
var imagesNames = ["1.tiff","2.tiff","3.tiff","4.tiff","5.tiff","6.tiff","7.tiff","8.tiff","9.tiff","10.tiff","11.tiff","12.tiff","13.tiff","14.tiff","15.tiff"]
var images = [UIImage]()
for i in 0..<imagesNames.count{
images.append(UIImage(named: imagesNames[i])!)
}
imageView.animationImages = images
imageView.animationDuration = 2
imageView.startAnimating()
Timer.scheduledTimer(timeInterval: 4.0, target: self, selector: #selector(timeToMoveOn), userInfo: nil, repeats: true)
}
注意:如果您不想让动画重复。在定时器功能中将repeat设置为false
func timeToMoveOn() {
//Do you stuff here.After animation finished
print("It Workes")
}
//To hide status bar.If you want to hide statusBar.
override var prefersStatusBarHidden: Bool {
return true
}
输出:
关于ios - 在 iOS 中播放准备好的动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40215535/