【问题标题】:Change fill color of a part of a combined path with animation?使用动画更改组合路径的一部分的填充颜色?
【发布时间】: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 有动画。我该怎么做?

【问题讨论】:

标签: ios animation uibezierpath cashapelayer cgpath


【解决方案1】:

您可以清理当前蒙版,并使用描边/填充颜色重新绘制任何贝塞尔路径并将它们组合在一起,然后重新设置。而绘制动画可以参考How to Animate CoreGraphics Drawing of Shape Using CAKeyframeAnimation

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 2012-03-20
    • 1970-01-01
    • 2012-06-08
    相关资源
    最近更新 更多