WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

Circular Animation not showing when app comes back to the foreground.

Forums > iOS

I'm building a timer app with UIKit that has a circular animation. I'm using CABasicAnimation for the circular animation. Presently, when the app goes to the background, the timer and animation are supposed to pause. The timer pauses alright, and when the app is brought back to the foreground, I can tap the resume button to continue the timer countdown. The challenge I'm having is that the circular animation does not reappear when the app comes back to the foreground. Please does anyone have any ideas how I can make the animation reappear when the app comes back to the foreground, so when I press the resume button, both the animation and timer continue?


Hello! I finally found a solution to the challenge above. Just in case anyone has a similar issue in the future, this stackoverflow thread has the solution: https://stackoverflow.com/questions/7568567/restoring-animation-where-it-left-off-when-app-resumes-from-background


Excellent. Thanks for posting a solution.

It might help others if you explained the general problem, then the coding approach that solved the issue.

Please be sure to mark your answer as SOLVED!


Hacking with Swift is sponsored by Emerge

SPONSORED Optimize your app’s startup time, binary size, and overall performance using Emerge’s advanced app optimization and monitoring tools. Reliably measure app size, speed up your app's startup time with Emerge's Launch Booster, and much more. Emerge is actively used by many of the top mobile development teams in the world.

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.