美文网首页
CABasicAnimation与CAKeyframeAnima

CABasicAnimation与CAKeyframeAnima

作者: j了个p | 来源:发表于2015-11-24 14:37 被阅读0次

-(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];

}

相关文章

网友评论

      本文标题:CABasicAnimation与CAKeyframeAnima

      本文链接:https://www.haomeiwen.com/subject/sovrhttx.html