我有一个从应用程序开始的动画。当这个动画完成时,我需要调用另一个函数,但我没有找到执行它的过程。
这是我的动画代码:
func bettyAnimation(){
var betty: UIImageView = UIImageView()
var bettyImageList: [UIImage] = []
for i in 1...77{
let imageName = "pantalla_02_betty_\(i).png"
bettyImageList += [UIImage(named: imageName)!]
}
self.view.addSubview(betty)
betty.animationRepeatCount=1
betty.animationImages = bettyImageList
betty.animationDuration = 6.0
betty.startAnimating()
Run Code Online (Sandbox Code Playgroud)
}
您需要将代码放入completion块中。
UIView.animateWithDuration(
// duration
1.0,
// delay
delay: 0.0,
options: nil,
animations: {
// put animation code here
}, completion: {finished in
// the code you put here will be executed when your animation finishes, therefore
// call your function here
}
)
Run Code Online (Sandbox Code Playgroud)