Reputation: 989
I have an animation that start with the app. When this animation finish, I need to call another function, but I don't find the process to do it.
This is my animation code:
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()
}
Upvotes: 2
Views: 4781
Reputation: 9419
You need to put the code inside the completion
block.
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
}
)
Upvotes: 6