我正在尝试为CAShapeLayar的strokeColor属性设置动画.我查看了文档,并声明它是一个可动画的属性.该代码用于动画postion.y但不是strokeColor.我很乐意得到任何帮助或建议
我用过的代码:
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"];
Run Code Online (Sandbox Code Playgroud)
在此先感谢,或者.