I have an UINavigationController. I made VC1 the rootViewController and programatically load VC2 from VC1 and then have the custom animation to go from VC1 to VC2. Standard. Everything is fine and good.
Now, I would like to have a custom animation between the two like so:
In sum, VC1 slides out of view while VC2 is beneath it. Just like a stack of paper where you slide away the first sheet (VC1) and thus reveal the sheet beneath (VC2).
So what I tried is the following code which is called from VC1 in order to get to VC2. But there are problems with it:
MyVC2 *vctwo = [[[MyVC2 alloc] init] autorelease];
CATransition *transition = [CATransition animation];
transition.duration = 1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromRight;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[[self navigationController] pushViewController:vctwo animated:YES];
The problems are the following:
- VC2 is not fixed in the background. It kind of slides in as well (even though I specified kCATransitionReveal). I want to be VC2 totally fixed in the background.
- VC1 fades out. I don't really know why. I did not use kCATransitionFade or the like, so I can't see where the fade comes from.
Any suggestions why I am not getting the expected results would be very much appreciated. Sorry if this is obvious, but I am trying this for hours now and got really frustrated.