CAKeyframeAnimation

来源:http://www.sh-fengwen.com 作者:鲜果干果 人气:115 发布时间:2019-10-08
摘要:UIView *_redView = [[UIView alloc] init]; _redView.frame = CGRectMake(100,100,200,200); _redView.backGroundColor = [UIColor redColor]; position移动 CAKeyframeAnimation*anim = [CAKeyframeAnimation animation]; //设置动画属性 anim.keyP

UIView *_redView = [[UIView alloc] init];

_redView.frame = CGRectMake(100,100,200,200);

_redView.backGroundColor = [UIColor redColor];

position移动

CAKeyframeAnimation*anim = [CAKeyframeAnimation animation];

//设置动画属性

anim.keyPath=@"position";

UIBezierPath*path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0,0,200,200)];

anim.path= path.CGPath;

anim.duration=2.0;

//取消反弹

anim.removedOnCompletion=NO;

anim.fillMode=kCAFillModeForwards;

anim.repeatCount = MAXFLOAT;

//kCAMediaTimingFunctionEaseInEaseOut:动画一开始比较慢,中间会加速,临近结束会变慢

anim.timingFunction= [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

[_redView.layer addAnimation:animforKey:nil];

rotation抖动效果

#define angle2radian /180.0* M_PI)

CAKeyframeAnimation*anim = [CAKeyframeAnimation animation];

anim.keyPath=@"transform.rotation";

anim.values=@[@(angle2radian,@(angle2radian,@(angle2radian];

anim.repeatCount=MAXFLOAT;

anim.duration=0.5;

[_redView.layer addAnimation:anim forKey:nil];

CATransition

CATransition*anim = [CATransition animation];

anim.type=@"pageCurl";

fade//交叉淡化过渡

push//新视图把旧视图推出去

moveIn//新视图移到旧视图上面

reveal//将旧视图移开,显示下面的新视图

cube//立方体翻滚效果

oglFlip//上下左右翻转效果

suckEffect//收缩效果,如一块布被抽走

rippleEffect//滴水效果

pageCurl//向上翻页效果

pageUnCurl//向下翻页效果

cameraIrisHollowOpen//相机镜头打开效果

cameraIrisHollowClose//相机镜头关上效果

anim.subtype=kCATransitionFromLeft;

//anim.startProgress = 0.5;

anim.duration=2;

[_redView.layer addAnimation:anim forKey:nil];

本文由美高梅游戏平台网站发布于鲜果干果,转载请注明出处:CAKeyframeAnimation

关键词:

上一篇:没有了

下一篇:MacOS中同时安装OpenCV2和OpenCV3并快速切换

最火资讯