I'm working on a little project where I want to draw a bezier curve. I want to be able to vary the lineWidth in different portions of the drawing.
Here's what I have:
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;
How would I vary the width of the line? One solution might be to have multiple UIBezierPaths with multiple CAShapeLayers, but it seems there should be a simpler, more elegant solution (something along the lines of specifying the lineWidth at the level where the UIBezierPath lines are specified).
Thanks!
UIBezierPath only has one lineWidth property, so it's not possible to draw varying line widths with one path. You would have to use multiple paths to achieve this effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With