How to change the Push and Pop animations in a navigation based app

前端 未结 25 1167
清酒与你
清酒与你 2020-11-22 12:46

I have a navigation based application and I want to change the animation of the push and pop animations. How would I do that?

Edit 2018

Ther

25条回答
  •  难免孤独
    2020-11-22 13:19

    From the sample app, check out this variation. https://github.com/mpospese/MPFoldTransition/

    #pragma mark - UINavigationController(MPFoldTransition)
    
    @implementation UINavigationController(MPFoldTransition)
    
    //- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
    - (void)pushViewController:(UIViewController *)viewController foldStyle:(MPFoldStyle)style
    {
        [MPFoldTransition transitionFromViewController:[self visibleViewController] 
                                      toViewController:viewController 
                                              duration:[MPFoldTransition defaultDuration]  
                                                 style:style 
                                            completion:^(BOOL finished) {
                                                [self pushViewController:viewController animated:NO];
                                            }
         ];
    }
    
    - (UIViewController *)popViewControllerWithFoldStyle:(MPFoldStyle)style
    {
        UIViewController *toController = [[self viewControllers] objectAtIndex:[[self viewControllers] count] - 2];
    
        [MPFoldTransition transitionFromViewController:[self visibleViewController] 
                                      toViewController:toController 
                                              duration:[MPFoldTransition defaultDuration] 
                                                 style:style
                                            completion:^(BOOL finished) {
                                                [self popViewControllerAnimated:NO];
                                            }
         ];
    
        return toController;
    }
    

提交回复
热议问题