則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。糾正這個問題。
躲閃你...怎麼樣?你有什麼嘗試?它怎麼不起作用?會發生什麼呢? –