UIStackView - leaving blank space on the stack?

I am trying to create a vertical UIStackView that contains subviews of varying sizes. They are assembled dynamically, and may or may not cover the entire height of the UIStackView parent. When they do not, I would like the subviews to "float" to the top, and just leave empty space below:

+-----------
|XXXXXXXXXX  <-subview 1
|YYYYYYYYYY  <-subview 2
|YYYYYYYYYY
|ZZZZZZZZZZ  <-subview 3
|
|            <-empty space
+-----------


So far I've only been able to achieve this by setting the UIStackView.distribution to Fill, and adding a dummy UIView "filler" at the bottom of the stack and mucking around with the Constraint @ syntax: "V:|-[filler(>=0@11)]-|". This sort of works but it seems like there ought to be a nicer approach.


Is there a cleaner way to do this?

Just embed your stack view inside a horizontal stack view and set the outer stack view's alignment to top.

Isn't there a gravity setting for this? Use "top" gravity group for your subviews, leave mid and bottom groups empty.

UIStackView - leaving blank space on the stack?
 
 
Q