Group Group Group Group Group Group Group Group Group

raywenderlich.com Forums

Updated Course: Beginning iOS Animations

In this beginning iOS animations course, you’ll learn how to create delightful animations in iOS. Start with simple animations using Auto Layout constraints, and then move to complex animations including springs, keyframes, view transitions, and more!


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/674-updated-course-beginning-ios-animations

In a view controller I have a simple UILabel animation:

    private func animateTipLabel() {
    let duration = 10.0
    
    UIView.animate(withDuration: duration, delay: 1.0, options: .transitionCrossDissolve, animations: {
        self.tipLabel.alpha = 1
    }, completion: { finished in
        if finished {
            UIView.animate(withDuration: duration, delay: 2.0, options: .transitionCrossDissolve, animations: {
                self.tipLabel.alpha = 0
            }, completion: { finished in
                if finished {
                    self.changeTipLabelName()
                    self.animateTipLabel()
                }
            })
        }
    })
}

However when the app enters background and then comes back to foreground, the animation is stopped and it does not play nor it resumes itself. How to resume the animation?

Hello there!

This is a bit outside the scope of our animation courses. If you have a looping animation, the complexity of the answer depends on whether or not you want to resume the animation from exactly where it left off when the app entered the background, which would involve dropping down to layer animations, or if you just want to start the animation anew.

Take a look at the documentation for Handling App State Transitions for an idea of where to start, in either case.