Dil*_*lip 4 uiviewcontroller uinavigationcontroller ios
是否可以更改ViewContoller Pop动画的Direction。
现在,当我们按下VC时,它会显示动画“从左向右滑动”和“从右向左弹出”。
但是我想在Pop 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;
干杯,这是 swift 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)
我用下面的代码..
在此添加 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
| 归档时间: | 
 | 
| 查看次数: | 3191 次 | 
| 最近记录: |