I have a view that has rows and columns of imageviews in it.
If this view is resized, I need to rearrange the imageviews positions.
This view is a subview of
In a UIView
subclass, property observers can be used:
override var bounds: CGRect {
didSet {
// ...
}
}
Without subclassing, key-value observation with smart key-paths will do:
var boundsObservation: NSKeyValueObservation?
func beginObservingBounds() {
boundsObservation = observe(\.bounds) { capturedSelf, _ in
// ...
}
}