3

我正在使用以下代码在导航堆栈中推送 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];
                     }];
4

3 回答 3

22

实际上过渡应该这样完成

//主视图

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

// 在视图控制器中

[UIView transitionWithView:self.navigationController.view
                  duration:0.75
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:^{
                    [self.navigationController popToRootViewControllerAnimated:NO];
                }
                completion:nil];
于 2013-09-24T13:21:29.100 回答
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];
于 2013-09-24T13:28:25.453 回答
2

在 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)
        })
于 2018-06-27T08:30:48.937 回答