1

Why is this happening?

enter image description here

This is my constraints:

enter image description here

Two stack views: horizontal and vertical, both distribution set on "Fill Equally".

What am I doing wrong?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Hrvoje
  • 696
  • 7
  • 22

2 Answers2

2

Your Vertical StackViews should be set to:

Alignment: Center
Distribution: Fill

And your Horizontal StackView should be set to:

Alignment: Fill
Distribution: Fill Equally

Result:

enter image description here

enter image description here

DonMag
  • 69,424
  • 5
  • 50
  • 86
1

The distribution property determines the size of the subviews along the stack view axis, in this case, .fillEqually on your vertical stack views will cause the switch and label to have the same height.

The alignment property will determine the position and size of the views in the other axis. If set to .fill, the default value, the view will have the same size as the stack view.

In this case, the stack view will assign a width to the switch and label as wide as the containing stack view, but switches have a fixed size, so they'll override that and remain a fixed width.

If you want the labels and switches to be centered, set alignment to .center.

EmilioPelaez
  • 18,758
  • 6
  • 46
  • 50