大家只要在UINavigationController的Category中push(pop)方法中调用下面这个方法就可以了
- (void)setAnimatedWithTransition{
CATransition *animation = [CATransition animation];
//动画时间
animation.duration = 1.0f;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//过渡效果
animation.type = @"pageCurl";
//过渡方向
animation.subtype = kCATransitionFromRight;
[self.view.layer addAnimation:animation forKey:nil];
}
如果只是应用淡入淡出效果,不要navigation push的动画,可以将animated设置为NO,即可实现。
其中的动画类型有:
//交叉淡化过渡
animation.type = kCATransitionFade;
animation.type = kCATransitionPush;
animation.type = kCATransitionReveal;
animation.type = kCATransitionMoveIn;
animation.type = @"cameraIrisHollowOpen";
animation.type = @"cameraIrisHollowClose";
//立方体效果
animation.type = @"cube";
//收缩效果,如一块布被抽走
animation.type = @"suckEffect";
// 页面旋转 -上下翻转效果
animation.type = @"oglFlip";
//水波纹
animation.type = @"rippleEffect";
//向上翻一页
animation.type = @"pageCurl";
//向下翻一页
animation.type = @"pageUnCurl";
注意:如果在某一个跳转上需要加这个动画,那就在push跳转之前调用这个方法,切记最后一句代码改成这样
[self.navigationController.view.layer addAnimation:animation forKey:nil];