Convenient view alignment
Enabled views have an align attribute that supports aligning matching attributes of views. For example, aligning the heights of two views:
Using align is especially convenient when you need to align several views at once:
In addition to all the regular constraint attributes like height and center_x in the examples above, align supports aligning the composite attributes size and center.
Convenient view placement within superview
Creating individual constraints can quickly become a bit of a bore. Thus the wrapper includes a number of methods for "docking" views.
For example, the following places constraints to the top and both sides, leaving height still undefined:
Following docking methods are available:
all, center, horizontal, vertical, horizontal_between, vertical_between, top, bottom, leading, trailing, top_leading, top_trailing, bottom_leading, bottom_trailing
The most specialized of these are the _between methods, which dock the view to the sides in one direction, and between the two given views in another. Here's an example:
By default, dock methods leave a margin between the edges of the superview and the view. This can be adjusted with the fit parameter:
Dock.MARGIN (the default) - standard margin
Dock.TIGHT - no margin
Dock.SAFE - align to the safe area insets, if applicable
You can also change the default by setting the Dock.default_fit parameter, e.g.:
Dock.default_fit = Dock TIGHT
Many dock methods support share and constant parameters.
share parameter can be used to define how much of the superview's area the view should take:
This is only exact if you use TIGHT fit, as there is no way to dynamically account for the space taken by margins.
constant parameter can be used to adjust the margins manually, although I feel that this is probably bad layout design.