Title might be a bit ambiguous so i'll get straight to the point. Within my Xcode project I've implemented a simple animation in my initial ViewController, which functions fine, but after leaving the initial View, and moving to another scene, and then returning to the initial view, the animation fails to restart and I can't figure out why.
Here's the relevant code from my initial view
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
//cloud animation
let oldCenter = cloud.center
let newCenter = CGPoint(x: oldCenter.x - 800, y: oldCenter.y)
UIView.animate(withDuration: 30.0, delay: 0.0, options:
[.curveLinear, .repeat], animations: {
self.cloud.center = newCenter
}, completion: nil)
//second cloud animation
let oldCenter2 = cloud2.center
let newCenter2 = CGPoint(x: oldCenter2.x + 800, y: oldCenter2.y)
UIView.animate(withDuration: 15.0, delay: 0.0, options:
[.curveLinear, .repeat], animations: {
self.cloud2.center = newCenter2
}, completion: nil)
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
}