我正在尝试调用[[self navigationController] popViewControllerAnimated:YES]
但是让动画从右向左滑动而不是从左向右滑动。有什么简单的方法吗?我想回到上一个观点。任何帮助表示赞赏。谢谢!
答案 0 :(得分:17)
这是一个可以在相反方向弹出视图控制器的方法。它为我工作100%
CATransition *transition = [CATransition animation];
transition.duration = 0.45;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
transition.type = kCATransitionFromRight;
[transition setType:kCATransitionPush];
transition.subtype = kCATransitionFromRight;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController popViewControllerAnimated:NO];
答案 1 :(得分:9)
有可能,请看一下我之前使用过的以下代码,并尝试让它适合自己。 Yu只需要更改setAnimationTransition
[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];
有一些不同类型的默认动画可供使用,苹果网站称这种动画是可能的:
typedef enum {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
} UIViewAnimationTransition;
因此,在您的情况下,您可能希望使用以下内容:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController popViewControllerAnimated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];