Disable clipping in CALayer

How to disable clipping in CALayer? I redefine drawInContext, but I want to draw lines that go beyond CALayer, and I don't want to do a separate drawing at the parent level for this to happen.

+3
source share
2 answers

You cannot draw using Quartz outside the borders of CALayer or UIView. As Noah suggests, you will need to extend the borders of the layer by a given amount in order to draw this.

You can still do this without executing any drawing in the parent layer if the property of the parent layer is masksToBoundsset to NO. Thus, even if your sublevel extends beyond the edge of the parent, it will still be drawn correctly.

+5
source

Well, it CALayerhas a property masksToBounds(which is set to NOdisables the default clipping to the borders of the layer), but I do not think that it affects the drawing of the layer itself - just clipping its sublayers. If for some reason you cannot expand the frame of the layer itself, you will need to set this property on this layer, add an additional sublevel with the dimensions that you want to draw inside, and move the drawing code to this sublevel.

+3
source

Source: https://habr.com/ru/post/1782362/


All Articles