I am using custom animation for navigation in my iOS app.
I have a subclass of UINavigationController that overrides the following methods:
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated { CATransition* transition = [CATransition animation]; transition.duration = 0.4; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; transition.type = kCATransitionPush;//kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom [self.view.layer addAnimation:transition forKey:@"Push"]; [super pushViewController:viewController animated:NO]; } - (UIViewController *)popViewControllerAnimated:(BOOL)animated { CATransition* transition = [CATransition animation]; transition.duration = 0.4; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; transition.type = kCATransitionPush;//kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade transition.subtype = kCATransitionFromRight; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom [self.view.layer addAnimation:transition forKey:@"Pop"]; UIViewController *poppedVC = [super popViewControllerAnimated:NO]; return poppedVC; }
I don’t remember the link, but I copied this code from the question here, and a small modification worked for me.
Now that I have ported my code to the iOS 7 SDK, a black background is displayed during navigation.
I posted a video here: Black background while navigating an iOS app to make it clear.
Note. The requirement in my application is that the animation will be opposite right and left and right right by default when push / pop. This code worked fine when I focused on iOS 5 and it didn't have a black background / screen.
source share