iOS-7-Custom-ModalViewController-Transitions
iOS-7-Custom-ModalViewController-Transitions copied to clipboard
Using generic UIViewControllers is fine
Simplified the code using generic UIViewControllers. There is no need to use your own classes here for MainView and SecondaryViews.
I also changed the duration so it uses the same you set on transitionDuration.
BTW, Thanks for this example, it really helped me :)
Thank you for your help, thanks to you I was able to animate the show of my second view controller :) But I have a simple question. How can I change the transition animation style ? Get a Dissolve animation instead of CoverVertical for exemple.
Thank you very much for your answer !!!
@KeiroMidori right now the animation is separated in two states:
[toVC.view setFrame:CGRectMake(0, screenRect.size.height, fromVC.view.frame.size.width, fromVC.view.frame.size.height)];
And inside the animation block:
[toVC.view setFrame:CGRectMake(0, 0, fromVC.view.frame.size.width, fromVC.view.frame.size.height)];
This is just setting the frame outside the screen to inside the screen. The animateWithDuration
does all the magic from first state to the second state.
You could comment these two lines and play with toVC.alpha
, maybe setting it to 0
first and to 1
inside the animation block. I haven't tried it but it should work this way.
It works ! But when I try to dismiss it with the CrossDissolve transition animation it makes a little flash on screen, maybe because it's too fast. I don't know how to make a dismiss dissolve animation manually.
@KeiroMidori uhm... interesting... maybe you should set the alpha 0 to the view in another place.
How do you dismiss the viewController? I just checked my project and I'm not using the transition on dismiss, only when it appears and I'm using [self dismissViewControllerAnimated:YES completion:nil];
to dismiss it. Not sure then, if you should create an animateTransition
separated method for dismissing it, that just sets the alpha to 0 inside the animation block.