Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To keep a UIBezierPath on top of a CAShapeLayer, you can add the UIBezierPath as a sublayer of the CAShapeLayer.

Here's an example:

let shapeLayer = CAShapeLayer()
// set the properties of the shape layer

let bezierPath = UIBezierPath(rect: CGRect(x: 0, y: 0, width: 100, height: 100))
let pathLayer = CAShapeLayer()
pathLayer.path = bezierPath.cgPath
// set the properties of the path layer

shapeLayer.addSublayer(pathLayer)

In this example, the UIBezierPath is created and added as a sublayer of the CAShapeLayer. The path layer is set to use the bezier path, and both layers can have their properties set independently.

Make sure to add the path layer as a sublayer of the shape layer to keep it on top.