翻转过渡uinavigationcontroller推

时间:2013-09-24 13:16:29

标签: ios objective-c uinavigationcontroller

我正在使用以下代码

在导航堆栈中推送UIViewController
[UIView animateWithDuration:0.75
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         [self.navigationController pushViewController:ViewController animated:NO];
                         [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
                     }];

现在当我按回来时,我希望它能做同样的动画,但它不起作用。知道为什么吗?

ViewController.m中的

[UIView animateWithDuration:0.75
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         [self.navigationController popToRootViewControllerAnimated:NO];
                         [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
                     }];

3 个答案:

答案 0 :(得分:21)

实际上应该像这样进行转换

//的MainView

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

//在viewcontroller中

[UIView transitionWithView:self.navigationController.view
                  duration:0.75
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:^{
                    [self.navigationController popToRootViewControllerAnimated:NO];
                }
                completion:nil];

答案 1 :(得分:2)

//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];

答案 2 :(得分:0)

在Swift 4中:

推送:

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

弹出窗口

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