常用的三种动画表现效果

常用的三种动画表现效果

在iPhone开发中,我们常常需要在不同的页面之间做动画切换,这样看起来更加好看。基本动画有以下三种:
1、UIView   
UIView官方提供五种动画效果供大家使用,分别为:

UIViewAnimationTransitionNone; 不使用动画
UIViewAnimationTransitionFlipFromLeft;从左向右旋转翻页
UIViewAnimationTransitionFlipFromRight;从右向左旋转翻页
UIViewAnimationTransitionCurlUp; 卷曲翻页,从下往上
UIViewAnimationTransitionCurlDown; 卷曲翻页,从上往下
例子:

[UIView beginAnimations:@"animationID" context:context];//开始一个动画块,第一个参数为动画块标识
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//设置动画块中的动画属性变化的曲线,此方法必须在beginAnimations和commitAnimations方法中。
[UIView setAnimationDuration:kDuration];//设置动画的持续时间
[UIView setAnimationRepeatAutoreverses:NO];//设置是否自动反转当前的动画效果
[UIView setAnimationTransition:transition forView:self.view cache:YES];//设置过渡的动画效果,此处第一个参数可使用上面5种动画效果
[self.view exchangeSubviewAtIndex:green withSubviewAtIndex:blue];//页面翻转
[UIView commitAnimations];//提交动画


2、CATransition

CATransition官方提供4种动画效果,分别为:

animation.type = kCATransitionFade;//渐渐消失
animation.type = kCATransitionPush;//推出
animation.type = kCATransitionReveal;//与MoveIn相反
animation.type = kCATransitionMoveIn;//覆盖进入

例子:

 CATransition *animation = [CATransition animation];//初始化动画
 animation.duration = kDuration;//间隔的时间
 animation.timingFunction = UIViewAnimationCurveEaseInOut;
 animation.type = kCATransitionFade;//渐渐消失 设置动画效果
  animation.subtype = kCATransitionFromLeft;//设置动画的方向,有四种,分别为
  animation.subtype = kCATransitionFromBottom;
 animation.subtype = kCATransitionFromRight;
 animation.subtype = kCATransitionFromTop;
[[self.view layer] addAnimation:animation forKey:@"animation"];

3、私有动画

私有动画是在CATransition的基础上,设置animation.type,可以提供一下几种选择:

animation.type = @"cube";//像立方体那样翻转

animation.type = @"suckEffect";//吸入,渐渐缩小,与删除照片的动画一样




 animation.type = @"oglFlip";//上下旋转,当subType为fromleft或者fromRight时,与UIViewAnimationTransitionFlipFromLeft;和
UIViewAnimationTransitionFlipFromRight一样

animation.type = @"rippleEffect";//水波效果


animation.type = @"pageCurl";//卷曲与UIViewAnimationTransitionCurlUp一样

animation.type = @"pageUnCurl";//卷曲与UIViewAnimationTransitionCurlDown一样

animation.type = @"cameraIrisHollowOpen";//摄像头开

animation.type = @"cameraIrisHollowClose";//摄像头关
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值