Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIStackView Form Layout

I'm creating a basic form with various fields. I'd like to use UIStackView to layout all the controls. How would I do the following so the controls are aligned correctly? Is the UIStackView the correct way to do this?

enter image description here

like image 993
Mr Rogers Avatar asked Oct 07 '15 16:10

Mr Rogers


People also ask

What is a UIStackView?

A streamlined interface for laying out a collection of views in either a column or a row.

What is Stackview alignment?

A layout where the stack view aligns the center of its arranged views with its center along its axis. case leading. A layout for vertical stacks where the stack view aligns the leading edge of its arranged views along its leading edge.

What is UISV spacing?

UISV-spacing constraints simply add the same spacing between each of the subsequent subviews. The spacing is defined by the value of the stack view spacing property.


1 Answers

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

This makes sense in that if you later change one of controls to a different control (say a popup button), you can keep the label and control baselines aligned.

like image 140
Mark Lilback Avatar answered Oct 17 '22 06:10

Mark Lilback