我将尝试动画化CAShapeLayar的strokeColor属性。我查看了文档,文档指出它是一个可动画化的属性。该代码可以用于动画化position.y但无法用于strokeColor。如果能提供任何形式的帮助或建议,我将非常感激。
我使用的代码:
提前感谢您, Or。
我使用的代码:
lyr.fillColor = [[UIColor clearColor] CGColor];
lyr.lineWidth = 3.8;
lyr.strokeColor = [[UIColor yellowColor] CGColor];
lyr.position = CGPointMake(160, 431);
lyr.anchorPoint = CGPointMake(.5f, .5f);
[self.view.layer addSublayer:lyr];
CABasicAnimation *basicAnimation = [CABasicAnimation animationWithKeyPath:@"strokeColor"];
basicAnimation.fromValue = [lyr valueForKey:@"strokeColor"];
basicAnimation.toValue =[NSValue valueWithPointer:[[UIColor clearColor] CGColor]];
basicAnimation.duration = 2;
basicAnimation.repeatCount = 10;
basicAnimation.autoreverses = YES;
[lyr addAnimation:basicAnimation forKey:@"strokeColor"];
提前感谢您, Or。