2017:
The literal answer to this question:
"CALayers didn't get resized on its UIView's bounds change. Why?"
is that for better or worse:
needsDisplayOnBoundsChange
defaults to false (!!) in CALayer
.
solution,
class CircularGradientViewLayer: CALayer {
override init() {
super.init()
needsDisplayOnBoundsChange = true
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override open func draw(in ctx: CGContext) {
go crazy drawing in .bounds
}
}
Indeed, I direct you to this QA
https://stackoverflow.com/a/47760444/294884
which explains, what the hell the critical contentsScale
does. You usually need to set that, when you set needsDisplayOnBoundsChange
.