I'm working on a drawing app, where user should be able to both fill locked areas and simply draw lines on finger moves.
Locked areas are provided as SVGs (paths), so I'm using SVGKit library to render them on the screen (as CAShapeLayers within a view). Then basically use fillColor on proper layer to fill it on touch.
However, for lines drawing then Core Graphics comes into play (CGContextStrokePath), and lines are always drawn below everything contained within CALayers hierarchy. So basically below filled areas.
What I'm trying to reach is a system where last applied drawing is always on top. So that applying fill overrides any lines in the area, and next drawing a line shows it above filled zone.
Seems that CGLayer's z-index is less than CALayer's one, and I need some other approach for my goal...
CAShapeLayer is designed to hold CGPath instances and render them, so I'd add a CAShapeLayer at the point in your layer-hierarchy where you want it to appear, and modify the CGPath property on that.