我正在做一个小项目,我想在其中绘制一条贝塞尔曲线。我希望能够改变绘图不同部分的 lineWidth
。
这是我所拥有的:
CAShapeLayer *pathLayer = [CAShapeLayer layer];
pathLayer.frame = self.animationLayer.bounds;
pathLayer.bounds = pathRect;
pathLayer.geometryFlipped = YES;
pathLayer.path = path.CGPath;
pathLayer.strokeColor = [[UIColor blackColor] CGColor];
pathLayer.fillColor = nil;
pathLayer.lineWidth = 1.0f;
pathLayer.lineJoin = kCALineJoinBevel;
如何改变线条的宽度?一种解决方案可能是使用多个 UIBezierPath
和多个 CAShapeLayer
,但似乎应该有一个更简单、更优雅的解决方案(类似于指定 >lineWidth
位于指定 UIBezierPath
行的级别。
谢谢!
最佳答案
UIBezierPath
只有一个 lineWidth
属性,因此不可能用一条路径绘制不同的线宽。您将不得不使用多个路径来实现此效果。
关于iphone - 改变 CAShapeLayer 中的线宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7843661/