创建一个CATransition,并将其应用到navigationController的view上
//设置动画,使跳转方向为从左侧进来
//CATransition 对象创建
CATransition *transition = [CATransition animation];
///时间间隔 1.0f最慢 0.1f最快
transition.duration = dur;
///动画的开始与结束的快慢
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//上一行也可以写为 transition.timingFunction = UIViewAnimationCureEasyInOut;
///设置动画效果
transition.type = transType ;
/* type的其他类型:
kCATransitionFade 交叉淡化过渡
kCATransitionMoveIn 新视图移到旧视图上面
kCATransitionPush 新视图把旧视图推出去
kCATransitionReveal 将旧视图移开,显示下面的新视图
*/
///设置动画方向
transition.subtype = subType;
/* subtype的其他类型
kCATransitionFromRight; 从右面进来
kCATransitionFromLeft; 从左面进来
kCATransitionFromTop; 从上面进来
kCATransitionFromBottom; 从下面进来
*/
[self.navigationController.view.layer addAnimation:transition forKey:@"transitionToAddNew"];
网友评论