A layout that has size constraints.
Alignment along a dimension defaults to .fill if there is no maximum constraint along that dimension and .center otherwise.
Flexibility along a dimension defaults to .inflexible if there is an exact constraint on that dimension, and .defaultFlex otherwise.
Constraints are enforced with the following precedence: 1. The maxSize paremeter of measurement. 2. The SizeLayout’s maxSize 3. The SizeLayout’s minSize
In other words, if it is impossible to satisfy all constraints simultaneously then constraints are broken starting with minSize.
Some common use cases:
// A fixed size UIImageView. SizeLayout<UIImageView>(width: 50, height: 50) // A 1px tall divider that fills the width of its parent. SizeLayout<UIView>(height: 1) // A label with maximum width. SizeLayout<UIView>(maxWidth: 100, sublayout: LabelLayout(text: "Spills onto two lines")) // A label with minimum width. SizeLayout<UIView>(minWidth: 100, sublayout: LabelLayout(text: "Hello", alignment: .fill))
open func measurement(within maxSize: CGSize) -> LayoutMeasurement
The maximum size available to the layout.
The minimum size required by the layout and its sublayouts given a maximum size. The size of the layout MUST NOT exceed
The rectangle that the layout must position itself in.
A measurement which has size less than or equal to
rect.sizeand greater than or equal to
A complete set of frames for the layout.