I've a ViewController that have some components, UILabels and UITextFields. I wants that the distance between them is uniform, 2 Points Top and Bottom, for example. So far, I adjust manually the distance. I wants know if exists a way to make this automatically. I tried select all UIViews and set constraints, but not works.
Actually layout:
When I tried set all components constraints:
Not works perfectelly:
I wants that the distance between them is uniform, 2 Points Top and Bottom, for example.
For this kind of work UIStackView
do the best job. Simply select all view, check Embed In Stack
:
And then specify the Spacing
value (note, that sometimes you also need to change the Axis
parameter, but in most cases initial value is correct for your ui elements):
Result (distance between all labels is 8):