1
简而言之,只有部分图标必须在某些情况下改变颜色。用动画改变组合路径的一部分的填充颜色?
我在UIView
内绘制曲线图标。绘图boilds 到几条路径结合在一起,这样的(SWIFT代码):
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,你可以用它来改变它在动画中的填充颜色。请参阅此答案:http://stackoverflow.com/a/4129155/2631081 – Blip