Flip transition uinavigationcontroller push

前端 未结 3 1982
粉色の甜心
粉色の甜心 2021-01-01 07:31

I am pushing a UIViewController in a navigation stack using the following code

[UIView animateWithDuration:0.75
                     animations:^{
                   


        
相关标签:
3条回答
  • 2021-01-01 08:12
    //FirstViewController
    [UIView beginAnimations:@"animation" context:nil];
    [UIView setAnimationDuration:0.8]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
    [self.navigationController pushViewController: viewcontroller
     animated:NO];
    [UIView commitAnimations];
    
    //SecondViewController
    [UIView beginAnimations:@"animation" context:nil];
    [UIView setAnimationDuration:0.8];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO]; 
    [self.navigationController popViewControllerAnimated:NO];
    [UIView commitAnimations];
    
    0 讨论(0)
  • 2021-01-01 08:20

    Actually the transition should be done like this

    //MainView

    [UIView transitionWithView:self.navigationController.view
                          duration:0.75
                           options:UIViewAnimationOptionTransitionFlipFromRight
                        animations:^{
                            [self.navigationController pushViewController:viewcontroller animated:NO];
                        }
                        completion:nil];
    

    // in viewcontroller

    [UIView transitionWithView:self.navigationController.view
                      duration:0.75
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:^{
                        [self.navigationController popToRootViewControllerAnimated:NO];
                    }
                    completion:nil];
    
    0 讨论(0)
  • 2021-01-01 08:22

    In Swift 4:

    Push:

    UIView.transition(with: (self.navigationController?.view)!, duration: 0.75, options: .transitionFlipFromRight, animations: {
                self.navigationController?.popViewController(animated: true)
            })
    

    Pop:

      UIView.transition(with: (self.navigationController?.view)!, duration: 0.75, options: .transitionFlipFromLeft, animations: {
                self.navigationController?.popViewController(animated: true)
            })
    
    0 讨论(0)
提交回复
热议问题