则strokeColor我一直不成功,在使用的答案从this previous线程动画上CAShapeLayer
闪烁的行程,很多的搜索后,我可以找到使用动画的CABasicAnimation
中风没有其他例子。动画效果CAShapeLayer与CABasicAnimation
我想要做的是有两个颜色之间的脉冲我的CAShapeLayer
脉冲。使用CABasicAnimation
为不透明工作正常,但[CABasicAnimation animationWithKeyPath:@"strokeColor"]
逃避我,我会很感激任何有关如何成功实施的建议。
CABasicAnimation *strokeAnim = [CABasicAnimation animationWithKeyPath:@"strokeColor"];
strokeAnim.fromValue = (id) [UIColor blackColor].CGColor;
strokeAnim.toValue = (id) [UIColor purpleColor].CGColor;
strokeAnim.duration = 1.0;
strokeAnim.repeatCount = 0.0;
strokeAnim.autoreverses = NO;
[shapeLayer addAnimation:strokeAnim forKey:@"animateStrokeColor"];
// CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
// opacityAnimation.fromValue = [NSNumber numberWithFloat:0.0];
// opacityAnimation.toValue = [NSNumber numberWithFloat:1.0];
// opacityAnimation.duration = 1.0;
// opacityAnimation.repeatCount = 0.0;
// opacityAnimation.autoreverses = NO;
// [shapeLayer addAnimation:opacityAnimation forKey:@"animateOpacity"];
取消注释不透明度动画会导致预期的不透明度消失。笔画动画不起作用。一个隐式的strokeColor改变动画的预期,但我希望记录确认strokeColor可以使用CABasicAnimation显式动画。
更新:具体问题是shapeLayer.path为NULL。纠正这个问题。
躲闪你...怎么样?你有什么尝试?它怎么不起作用?会发生什么呢? –