Question

My question is very similar to this one:

Seamlessly flip from one modal view to another, without showing a solid colour background

I followed the advice and ran into the same problem with the suggested solution - the entire screen flips, not just the modal. I had given up on this being possible, until the designer here showed me an example from the Pinterest app. I'm including an animated gif here. You can see that the background (with the 'x' close button) does not flip. Any ideas how this could be done?

Thanks!

enter image description here

Was it helpful?

Solution

This is in fact quite easy to achieve using simple UIView animations:

[UIView transitionWithView:viewToAnimate
                  duration:0.3
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:^{
                    // TODO: Animations here
                    viewToHide.hidden = YES;
                    viewToShow.hidden = NO;
                }

As you may note, the key here for the flip is the option UIViewAnimationOptionTransitionFlipFromLeft. Use it along with UIViewAnimationOptionTransitionFlipFromRight to obtain the same result that you are seeing in the GIF.

Only the viewToAnimate and its contents will flip, everything outside its hierarchy will stay still.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top