17
A
回答
49
要動態路徑
//setup the CAShapeLayer
myShapeLayer.strokeColor = [[UIColor blueColor] CGColor];
myShapeLayer.lineWidth = 5;
myShapeLayer.fillColor = [[UIColor yellowColor] CGColor];
//Display it!
[self.view.layer addSublayer:myShapeLayer];
//Animate path
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1.5f;
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
pathAnimation.repeatCount = 10;
pathAnimation.autoreverses = YES;
[myShapeLayer addAnimation:pathAnimation forKey:@"strokeEnd"];
//Animate colorFill
CABasicAnimation *fillColorAnimation = [CABasicAnimation animationWithKeyPath:@"fillColor"];
fillColorAnimation.duration = 1.5f;
fillColorAnimation.fromValue = (id)[[UIColor clearColor] CGColor];
fillColorAnimation.toValue = (id)[[UIColor yellowColor] CGColor];
fillColorAnimation.repeatCount = 10;
fillColorAnimation.autoreverses = YES;
[myShapeLayer addAnimation:fillColorAnimation forKey:@"fillColor"];
我希望這有助於:)
+0
我會添加fromValue和toValue可能是CGMutablePathRef對象來動畫改變路徑本身,使用鍵@「路徑」。上述改變對我的目的起作用。謝謝。 – webjprgm 2014-10-06 22:35:13
相關問題
- 1. CAShapeLayer路徑動畫
- 2. CAShapeLayer動畫無需更新路徑
- 3. 如何將CAShapeLayer的路徑動畫順暢地移動到另一個路徑?
- 4. 動畫CAShapeLayer通路改變
- 5. 更改所選CAShapeLayer的fillColor
- 6. 動畫CAShapeLayer派
- 7. 動畫CAShapeLayer與波動畫
- 8. 繪製沒有fillColor的CAShapeLayer層
- 9. CAShapeLayer路徑變爲彩色
- 10. 動畫路徑?
- 11. 路徑動畫
- 12. CAShapeLayer動畫效果路徑毛刺/忽明忽暗(從橢圓RECT和背面)
- 13. CAShapeLayer沒有動畫
- 14. 如何動畫CAShapeLayer的填充?
- 15. 如何使我的UIBezierPath動畫與CAShapeLayer?
- 16. CAShapeLayer和動畫位置問題
- 17. 如何爲svg路徑創建動畫?
- 18. 如何動畫CAShapleLayer的路徑更改?
- 19. 如何實現路徑動畫?
- 20. 如何繪製svg路徑動畫
- 21. CAShapeLayer動畫彩色問題
- 22. iOS動畫:CADisplayLink vs CAShapeLayer
- 23. 動畫CAShapeLayer:完成時做
- 24. 添加比例動畫CAShapeLayer
- 25. CAShapeLayer路徑在動畫後消失 - 需要它留在同一個地方
- 26. 沿着盆景路徑動畫動畫
- 27. WPF動畫路徑速度和暫停
- 28. SVG路徑:動畫和合並
- 29. 從多個CG路徑構造CAShapeLayer
- 30. 動畫填充路徑 - Silverlight
當你設置它自動動畫。你能否提供更多關於你想要達到的內容的信息? – jrturton 2013-03-27 07:53:05