UIStackView Form Format

I create a basic form with various fields. I would like to use UIStackView to compose all the controls. How would I do the following so that the controls are aligned correctly? Is this UIStackView ?

enter image description here

+5
source share
2 answers

You can definitely use StackViews to achieve this.

How you arrange StackViews depends on how you want to control the alignment.

Here is what I recommend:

  • Put your tags on one vertically aligned stack and
  • Place text fields in another vertical stack alignment
  • Place the two stack views in the horizontal stack alignment.

Most likely, you want your distribution populate equally across the two smaller stack views, and then set the spacing parameter to the same for each smaller stack. Finally, you can set the spacing in the horizontal stack view to set the space between your text and your text fields. (This final part is the reason I would set them like this.)

+5
source

Apple suggests creating horizontal stack views with each label and field, and then placing them in a vertical stack view.

This makes sense if you later change one of the controls to another control (for example, a pop-up button), you can maintain alignment of labels and controls.

+6
source

Source: https://habr.com/ru/post/1233181/


All Articles