简体   繁体   中英

iOS modal view transition flip without whole screen flipping

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!

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM