Rogare
Rogare

Reputation: 3274

iOS - Keep background animation across view controllers

I'm using a basic UINavigationController design for the settings pages of an app. Each settings page is its own view controller (with xib), and each page has the same background image.

I've since built a view-based animation to replace the background image, and I'd like it to play uninterrupted while the user moves from page to page. In other words, it's as though each settings page had a transparent background, and beneath all of them was a single instance of my animating view.

How would I go about doing this?

So far, I've tried just putting the animation on each page separately, but the transitions look a bit too sloppy for me. I'd also considered somehow having a single UIView with all necessary animations underneath my navigation controller, but not sure a) if that's feasible, and b) how to go about that.

Thanks for reading.

Upvotes: 0

Views: 867

Answers (1)

Oliver Atkinson
Oliver Atkinson

Reputation: 8029

Sounds like you want to be using "Container View Controllers"

You can read up on the Apple documentation here: https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html


The solution would be to have one master view controller which holds onto your settings view controllers. The settings view controllers background is transparent so you see the background of the master view controller.

As for the animation see Listing 14-3 Transitioning between two view controllers on the link I provided you.

Upvotes: 1

Related Questions