It is known that the main/root layer of a UIView
, e.g., view.layer
, will resize automatically to fill the frame of the UIView
(however, a root layer's sublayers will not automatically resize).
After subclassing CALayer
like:
class CustomLayer : CALayer {
//...
}
What methods can I implement to "draw" content so that the layer will automatically resize if used as the root CALayer of a view?
The reason I ask this is because I am current calling methods such as:
UIBezierPath(roundedRect: self.view.frame, byRoundingCorners: [.topLeft], cornerRadii: CGSize(width: 17, height: 15))
To update the path of a CALayer, but it would be amazing to be able to create a custom CALayer
that can act as a root layer for a UIView
so I don't need to consistently update its path.
Does anyone have any advice for this? Ultimately I'm striving to have a layer that can support unique radii for each corner that will automatically fill the UIView
and resize without having to consistently update the frame.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…