I want to draw a shape hole in an @IBDesignable view. For this I need the size of a view, which is above in the view hierarchy. This view changes it's size by constraints.
How to retrieve the frame? May this is not possible at all, because the view we are depending on is drawn later? But it's frame size may be retrievable early?
<MainView>
| <View>
| | <ViewWithShape>
| <ViewWeDependOn>
The shape is drawn in layoutSubviews:
override func layoutSubviews() {
super.layoutSubviews()
if !(holeLayer != nil) {
holeLayer = CAShapeLayer()
layer.mask = holeLayer
let rect = bounds // I need the frame HERE
let path = UIBezierPath(quadrantHoleInsideRect: rect)
holeLayer.path = path.CGPath
}
}