masksToBounds
masksToBounds is a boolean property of a layer (CALayer) that controls whether the layer’s contents and its sublayers are clipped to the layer’s bounds. When masksToBounds is true, anything drawn outside the layer’s rectangular bounds is not visible; when false, drawing outside may be visible depending on the rest of the layer tree and compositing.
Default value is false. The property is commonly used with cornerRadius to create rounded corners by clipping
A common pattern to preserve both a rounded appearance and a shadow is to use a container
In UIKit, the equivalent behavior is provided by UIView’s clipsToBounds property, which maps to the underlying
Performance considerations: turning on masksToBounds can trigger offscreen rendering in certain cases, especially with complex sublayers,
Related concepts: the layer also supports an explicit masking layer via the mask property, which defines arbitrary