What is the correct way to change the transition effect of a UINavigationController

I saw a lot of people asking about how to click / pop UINavigationControllerusing other animations besides the standard animation, for example flipor curl.

The problem is that either the question / answer was relatively old, which means that it has things like [UIView beginAnimations:](example here ) or they use two very different approaches.

First, use the UIView selector transitionFromView:toView:duration:options:completion:before clicking on the controller (with the animation flag set to NO), for example:

UIViewController *ctrl = [[UIViewController alloc] init];
[UIView transitionFromView:self.view 
                toView:ctrl.view 
                duration:1 
                options:UIViewAnimationOptionTransitionFlipFromTop
                completion:nil];

[self.navigationController pushViewController:ctrl animated:NO];

Another is to use explicitly CoreAnimationwith the CATransactionfollowing:

// remember you will have to have the QuartzCore framework added to your project for this approach and also add <QuartzCore/QuartzCore.h> to the class this code is used
CATransition* transition = [CATransition animation];
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
transition.duration = 1.0f;
transition.type =  @"flip"; 
transition.subtype = @"fromTop"; 
[self.navigationController.view.layer removeAllAnimations];
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];

UIViewController *ctrl = [[UIViewController alloc] init];
[self.navigationController pushViewController:ctrl animated:NO];

There are pros and cons for both approaches.

, , "suckEffect", "cube" .

, . (.. CATransition), App Store ( , , , ), , , "cameraIris", "rippleEffect" ..

, QuartzCore CoreAnimation, UINavigationController fancier? , UIKit?

, , "" "", (kCATransitionFade, kCATransitionMoveIn ..), , ?

, , , ?

+3
1

AppStore, , , , . , , . , , CoreAnimation QuartzCore , . - , .

. COCOS2D . . , CoreAnimation, 30 , COCOS2D 3-5 . , COCOS2D (chipmunk).

+1

All Articles