如何在后退按钮上更改弹出视图控制器动画?

时间:2010-05-31 08:10:19

标签: iphone animation uinavigationcontroller

我正在使用以下语句推送我的视图控制器:

[[self navigationController] pushViewController:self.customViewController animatedWithTransition:UIViewAnimationTransitionFlipFromLeft];

现在当我按下后退按钮时,我想用uiviewanimationtransitionflipfromright来设置它的动画。

[self.navigationController popViewControllerAnimatedWithTransition:UIViewAnimationTransitionFlipFromLeft];

我该怎么办?

谢谢

3 个答案:

答案 0 :(得分:5)

这有助于您在后退按钮中设置动画。

[UIView  beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];

答案 1 :(得分:2)

推送:

MainView *nextView = [[MainView alloc] init];
[UIView animateWithDuration:0.75
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         [self.navigationController pushViewController:nextView animated:NO];
                         [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
                     }];

对于Pop:

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

https://stackoverflow.com/a/5889757/1915820

答案 2 :(得分:1)

请参阅此处了解自定义后退动画:

Prevent the animation when clicking "Back" button in a navigation bar?