可以改变ViewContoller流行动画的方向吗?
现在,当我们推VC的时候,它会显示动画幻灯片,从左到右,从右到左。
但我想要在流行VC上从左到右的动画幻灯片。
我试过使用UIViewAnimationTransition。
[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;发布于 2016-10-11 06:01:47
我使用了以下代码。
将此添加到didFinishLaunchingWithOptions中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//This line of code needed so you will not see the back window when its pop, match it with your app design.
self.window.backgroundColor = [UIColor whiteColor];
return YES;
}如果您的POP代码添加了这些代码,
CATransition* transition = [CATransition animation];
transition.duration = 0.4f;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[self.navigationController popViewControllerAnimated:NO];检查这个GIF的结果,
http://www.giphy.com/gifs/l2YSeBELE1phMEd5S
发布于 2017-11-12 15:39:02
干杯,这里是迅捷的3.0 ~ 4.0版本。
let transition = CATransition()
transition.duration = 0.4
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight
self.navigationController?.view.layer.add(transition, forKey: kCATransition)
self.navigationController?.popViewController(animated: false)发布于 2014-02-10 05:55:07
您可以在您的案例中使用[UIView beginAnimations:]。你需要的话可以用setTransitionStyle。查看苹果文档中的雪崩UIViewAnimationTransitionStyle,请参阅此class/uiview/uiview.html
https://stackoverflow.com/questions/21669863
复制相似问题