CABasicAnimation与CAKeyframeAnimation

-(void)superBilibiliCicle{

//CABasicAnimation *

CABasicAnimation* sizeTransform=[CABasicAnimationanimationWithKeyPath:@"transform"];

sizeTransform.fromValue=[NSValuevalueWithCATransform3D:CATransform3DIdentity];

sizeTransform.toValue=[NSValuevalueWithCATransform3D:CATransform3DMakeScale(10,10,1)];

CABasicAnimation* opacity=[CABasicAnimationanimationWithKeyPath:@"opacity"];

opacity.fromValue=[NSNumbernumberWithFloat:1.0];

opacity.toValue=[NSNumbernumberWithFloat:0.0];

CABasicAnimation* cicle=[CABasicAnimationanimationWithKeyPath:@"transform"];

cicle.fromValue=[NSValuevalueWithCATransform3D:CATransform3DIdentity];

cicle.toValue=[NSValuevalueWithCATransform3D:CATransform3DMakeRotation(M_PI,0,0,1)];

CAKeyframeAnimation* animation =[CAKeyframeAnimationanimationWithKeyPath:@"position"];

[animationsetValues:[NSArrayarrayWithObjects:[NSValuevalueWithCGPoint:CGPointMake(300,300)], [NSValuevalueWithCGPoint:CGPointMake(100,100)],nil]];

CAAnimationGroup* group=[CAAnimationGroupanimation];

//虽不造 但是sizeTransform 与 cicle可能互斥 不能一块用CATransform3DMakeScale和CATransform3DMakeRotation 不能一块用

group.animations=[NSArrayarrayWithObjects:animation,opacity,sizeTransform,nil];http://www.jianshu.com/users/9e1972b6e5f7

group.duration=3;

group.repeatCount=10;

[self.blackRect.layeraddAnimation:groupforKey:nil];

}

-(void)pathMove{

CGMutablePathRefpath=CGPathCreateMutable();

CGPathMoveToPoint(path,NULL,0,100);

CGPathAddLineToPoint(path,NULL,100,100);

CGPathAddLineToPoint(path,NULL,100,0);

CGPathAddLineToPoint(path,NULL,0,0);

CAKeyframeAnimation* keyAnimation=[CAKeyframeAnimationanimationWithKeyPath:@"position"];

[keyAnimationsetPath:path];

[keyAnimationsetDuration:3.0];

[keyAnimationsetAutoreverses:YES];

[self.blackRect.layeraddAnimation:keyAnimationforKey:nil];

}

-(void)pointMove{

CAKeyframeAnimation* keyAnimation=[CAKeyframeAnimationanimationWithKeyPath:@"position"];

[keyAnimationsetValues:[NSArrayarrayWithObjects:[NSValuevalueWithCGPoint:CGPointMake(0,100)],[NSValuevalueWithCGPoint:CGPointMake(100,100)],[NSValuevalueWithCGPoint:CGPointMake(100,0)],[NSValuevalueWithCGPoint:CGPointMake(0,0)],nil]];

[keyAnimationsetDuration:3.0];

[self.blackRect.layeraddAnimation:keyAnimationforKey:nil];

}

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

推荐阅读更多精彩内容