-1

I create a new view controller.

I add a vertical stack to it. Spacing = 0, Alignment = Center X, Fill Equally. I constrain it to the 4 edges of its superview with space = 0.\

I add 3 horizontal stacks inside the main stack.

For each of the the horizontal stacks: alignment = Center Y, Fill Equally, spacing 0.

I add two custom views inside each of these 3 stacks.

I constrain the width of one of these stacks to the width of the main stack.

The result is insane.

enter image description here

Why in the name of heaven isn't the result like this?

enter image description here

Duck
  • 34,902
  • 47
  • 248
  • 470

2 Answers2

1

You do not need any constraints except of the top, leading, bottom and trailing constraints for your outer (vertical) stack view. Make sure that you set the alignment property to Fill and the distribution property to Fill Equally for all (vertical and horizontal) stack views.

Result:

result

André Slotta
  • 13,774
  • 2
  • 22
  • 34
  • Thanks but this works for iOS but unfortunately not for macOS. There is no alignment FILL there. – Duck Jun 30 '19 at 15:36
0

I have found the solution: you must add a constrain in each of the custom views to Equal height of its stack view.

Duck
  • 34,902
  • 47
  • 248
  • 470