系统默认的NavigationController还不错,但是时间长了会有审美疲劳,今天在网上找了找资料,改变默认的动画效果。
1.添加QuartzCore并引入头文件
#import <QuartzCore/CoreAnimation.h>
2. PushView 的动画修改
CATransition *transition = [CATransition animation];
transition.duration = 1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromTop;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
self.navigationController.navigationBarHidden = NO;
[self.navigationController pushViewController:viewController animated:NO];
3.popView的动画
CATransition *transition = [CATransition animation];
transition.duration =0.4;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionReveal;
//transition.subtype = kCATransitionFromBottom;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
self.navigationController.navigationBarHidden = NO;
[self.navigationController popViewControllerAnimated:NO];
本文只是演示了如何修改动画,具体什么样的动画比较好看,还需要自己选择。
团结就是力量,ios开发者自己的推广联盟 QQ群173063969