Reputation: 1008
Currently, this animation repeats itself every 3ish seconds. I would like to have a wait time of 10 seconds in between repeating this animation. How can I accomplish this?
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animate(withDuration: 7.5, delay: 20,
options: .repeat,
animations: {
self.imageAnimate.center.x += self.view.bounds.width * 2
},
completion: nil
)
}
Upvotes: 1
Views: 2093
Reputation: 274500
Use a Timer
:
// note that I used 17.5 here because the animation itself takes 7.5 seconds
// so that will be 7.5 seconds of animating, 10 seconds of doing nothing
// and start animating again
Timer.scheduledTimer(withTimeInterval: 17.5, repeats: true) {
UIView.animate(withDuration: 7.5, animations: {
self.imageAnimate.center.x += self.view.bounds.width * 2
})
}
Upvotes: 3