I have a view that starts animating when a ViewController first opens. It works fine on initial launch, but when returning to the view after leaving the animation does not restart. The views are embedded in a Navigation controller
I tried placing the animation in several locations, including viewWillAppear, viewDidAppear and viewWillLayoutSubviews
I've placed a breakpoint in viewDidAppear and it does step through the code, but the animation does not restart.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
UIView.animate(withDuration: 20.0, delay: 0, options: [.autoreverse, .repeat, .curveLinear], animations: {
self.scrollingView.transform = CGAffineTransform(translationX: -350, y: 0)
}, completion: nil)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(true)
scrollingView.layer.removeAllAnimations()
}