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"】;