iOS用push跳转页面,也可以有动画

奋斗的七月

大家只要在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];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容