UINavigationController改变动画效果

@interface UINavigationController (CustomTransition)

- (void) pushWithCustomAnimation:(UIViewController *) controller;
- (void) popWithCustomAnimation;
@end

 

@implementation UINavigationController (CustomTransition)

- (void) pushWithCustomAnimation:(UIViewController *) controller {
    CATransition *transition = [CATransition animation];
    transition.duration = 0.3;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionMoveIn;
    transition.subtype = kCATransitionFromTop;
    transition.delegate = self;
    [self.view.layer addAnimation:transition forKey:nil];
    self.navigationBarHidden = NO;
    [self pushViewController:controller animated:NO];

}

- (void) popWithCustomAnimation {
    CATransition *transition = [CATransition animation];
    transition.duration =0.3;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionReveal;
    transition.subtype = kCATransitionFromBottom;
    transition.delegate = self;
    [self.view.layer addAnimation:transition forKey:nil];
    
    self.navigationBarHidden = NO;
    [self popViewControllerAnimated:NO];

}

@end

 

posted @ 2014-08-23 12:38  Dadada胖纸er  阅读(260)  评论(0编辑  收藏  举报