相关疑难解决方法(0)

使用Core动画为StrokeColor设置动画

我正在尝试为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)

在此先感谢,或者.

core-animation core-graphics ios

3
推荐指数
1
解决办法
2707
查看次数

标签 统计

core-animation ×1

core-graphics ×1

ios ×1