【发布时间】:2015-12-17 17:25:51
【问题描述】:
简单来说,我的图标的一部分必须在某些事件中改变颜色。
我在UIView 内绘制了一个带有曲线的图标。图纸沸腾了
像这样将多个路径组合在一起(快速代码):
let combinedPath = CGPathCreateMutableCopy(bezierPath.CGPath)
CGPathAddPath(combinedPath, nil, bezier2Path.CGPath);
CGPathAddPath(combinedPath, nil, bezier3Path.CGPath);
然后我像这样将组合路径添加到 UIView(obj-c,抱歉 混合):
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.frame = self.bounds;
shapeLayer.path = combinedPath;
self.layer.mask = shapeLayer;
现在在某个时间点我想更改填充颜色
只有一个bezierPath 有动画。我该怎么做?
【问题讨论】:
-
一个很好的方法是使用 CAShapeLayer,您可以使用它来更改动画中的填充颜色。请参考这个答案:stackoverflow.com/a/4129155/2631081
标签: ios animation uibezierpath cashapelayer cgpath