Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Swift - Hold animation between view controllers.

On an app I'm working on, I have a background animation which comprises of: 5 image views (displaying different colored shapes), which move radially outward, expand and get smaller as they do so. It creates a slow 'explosion' effect.

This animation is continuous. As some shapes fade to alpha = 0, other shapes appear at the center and move outward to replace these.

The app has two tabs, this animation only happens on one of the tabs. Is it possible that when I switch from tab A (with the animation), to tab B (without) that the animation will pause/hold, until I return to tab A?

Currently, when I switch between them the animation starts over entirely, losing all the shapes.

I have thought of a solution, but it's clunky: I could create some individually placed shapes, further out from the center, so that on viewDidAppear it would look as though the animation has paused. However, I was hoping there is a more elegant solution as this requires coding the 15ish new animations individually, rather than my current animation function just 'pausing'.

The animation comprises of a few CGAffineTransforms, called within a UIView.animate block.

Thanks in advance for any help!

Comments