CAaimatioGroup 动画组合

1.初始化

Calayer*kklayer=[[CALayer alloc]init];        

kklayer.backgrounColor-[[UIColor grayColor]CGColor];

kklayer.fram=CGRectMake(50.50.100.200);

2设定他的frame

kklayer.connerRadius=5; 圆角处理

【self.view.layer addsubview: kklayer】;增加到uiview的layer上面

移动kklayer的positio

CABasicAnimatio *animation=[CABasicAnimation animatio.animationWithkeyPath:@"position"];

animation.fromValue=[NSValue valueWithCGPoint:kklayer.position];

CGpoint topoint=kklayer.positon;

topoint.x+=180;

animation.toValue=[NSValue valueWithCGPoint:topoint];

以x轴进行旋转

CABAsicAnimation*rotateAnimation=[CABasicAnimation animationWithKeyPath:@"transfrom.rotation.x"];

rotateAnimation.fromValue=[NSNumber numberWithFloat:0.0];

rotateAnimation.toValue=[NSNumber numberwithFloat:6.0*M_PI];

对kklayer进行放大缩小

CABasiAnimation*scaoleAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale.x"];

scaleAnimation.duration=3;  从开始到结束的时间

scaleAnimation.autoreverses=YES; 当你设定这个属性为yes时在他打到目的是后,动画的返回到开始值,代替了值直接跳转到开始的值

scaleAnimation.fromVAlue=[NSNumner numberWithFloat:1.0];

scaoleAnimation.toValue=[NSNumber numberWithFolat:2.5];

scaleAnimation.fillmode=KCAfillMOdeForwards;

layer.contents=(id)imageTmp.cgimage

把上面的动画组合起来

CAAnimationGroup*group=[CAAnimationGroup  animation 】;

group.autoreverses=YES;

完成后反向完成

group.duration=3.0;

group.animations=[NSArray arrayWithObjects: animation,rotateAnimation,scaoleAnimation,nil];

group.repeatCount=NSNotFound;

动画结束以后,他会返回到自己原来的fram,如果不想到原来fram我们需要设定

group.fillMode=KCAFillModeForards;不反悔原来的地方(好像现在不能用了)

addAnimation(让动画开始)

【kklayer addAnimation:group forKey:@"kklayerMove"】;

 

转载于:https://my.oschina.net/zhangxiaoweishuaige/blog/741203

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值