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 fillcolor圆弧动画不起作用
- 4. CAShapeLayer动画无需更新路径
- 5. CAShapeLayer路径动画 - 缩小圆圈
- 6. CAShapeLayer路径动画有严重延迟
- 7. CAShapeLayer fillColor不呈现
- 8. 如何将CAShapeLayer的路径动画顺畅地移动到另一个路径?
- 9. 动画CAShapeLayer通路改变
- 10. 更改所选CAShapeLayer的fillColor
- 11. 动画CAShapeLayer/CAGradientLayer
- 12. 动画CAShapeLayer派
- 13. 动画CAShapeLayer与波动画
- 14. 绘制没有fillColor的CAShapeLayer层
- 15. CAShapeLayer路径变为彩色
- 16. 路径动画
- 17. 动画路径?
- 18. CAShapeLayer动画效果路径毛刺/忽明忽暗(从椭圆RECT和背面)
- 19. CAShapeLayer没有动画
- 20. 如何使我的UIBezierPath动画与CAShapeLayer?
- 21. 如何动画CAShapeLayer的填充?
- 22. 动画WPF路径
- 23. WPF路径动画
- 24. 动画svg路径
- 25. CAShapeLayer和动画位置问题
- 26. 如何为此路径创建动画?
- 27. 如何沿着路径制作动画
- 28. RaphaelJs:如何动画路径后转换
- 29. 如何实现路径动画?
- 30. 如何为svg路径创建动画?
当你设置它自动动画。你能否提供更多关于你想要达到的内容的信息? – jrturton 2013-03-27 07:53:05