Change line width in CAShapeLayer

I am working on a small project where I want to draw a Bezier curve. I want to be able to change lineWidth in different parts of the drawing.

Here is 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 can I change the line width? One solution might be to have multiple UIBezierPath with multiple CAShapeLayer s, but there should seem to be a simpler, more elegant solution (something like lineWidth lines at the level where the UIBezierPath lines UIBezierPath indicated).

Thanks!

+4
source share
1 answer

UIBezierPath has only one lineWidth property, so it is not possible to use different line widths with one path. To achieve this effect, you will have to use several ways.

+5
source

All Articles