我有这个代码显示两个视图控制器之间的转换,但问题是我想显示从推动视图控制器中的从右到左的过渡....
UIViewController *previousController = [self.childViewControllers objectAtIndex:[self.childViewControllers count]-2];
[self transitionFromViewController:previousController toViewController:controller duration:0.5 options:UIViewAnimationOptionAllowAnimatedContent animations:NULL completion:NULL];
任何帮助将不胜感激
答案 0 :(得分:1)
你可以使用这样的东西......
(需要< QuartzCore / QuartzCore.h>)
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[previousController layer] addAnimation:animation forKey:@"SwitchToView"];
答案 1 :(得分:1)
我认为这是你想要的更好的方法,
NSMutableArray *vcs = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
UIViewController *previousController = [self.childViewControllers objectAtIndex:[self.childViewControllers count]-2];
[vcs insertObject:previousController atIndex:[vcs count]-1];
[self.navigationController setViewControllers:vcs animated:NO];
[self.navigationController popViewControllerAnimated:YES];