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

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

4

3 回答 3

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>

于 2012-12-06T06:26:45.710 回答
3

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

于 2012-12-06T06:22:55.233 回答
1

如果你已经被推送到 viewController 你可以使用这个:

[self.navigationController popViewControllerAnimated:YES]
于 2012-12-06T06:16:40.833 回答