如何从左侧加载视图?

时间:2012-12-06 06:13:42

标签: iphone ios5 uiviewcontroller uiviewanimation

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated

此功能从右侧加载视图。如何从左侧加载视图?

3 个答案:

答案 0 :(得分:7)

这是

CATransition *animation = [CATransition animation];
[[self navigationController] pushViewController:elementController animated:NO];
[animation setDuration:0.45];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
[[elementController.view layer] addAnimation:animation forKey:@"SwitchToView1"];

为此,您必须#import <QuartzCore/QuartzCore.h>

答案 1 :(得分:3)

不要认为有现成的方法可以做到这一点。您必须使用animateWithDuration:delay:options:animations:completion:animateWithDuration:animations:completion:(或任何其他动画方法)自行为视图设置动画,并相应地更改视图的帧,以便从右侧进行动画制作。 希望这会有所帮助:)

答案 2 :(得分:1)

如果你已经被推到了viewController,你可以使用它:

[self.navigationController popViewControllerAnimated:YES]