So, I have a UIStackView
that contains four (4) UIView
s. If I remove one (1) of those UIView
s, the other three (3) will fill the entire space in the UIStackView
.
MY QUESTION:
How can I add a max height on a UIView
so that it won't fill the entire space of the UIStackView
even though the distribution is filled equally? I read something about adding a constraint but I'm not able to make it work. I'm using swift by the way.
Thank you.
case fillProportionally. A layout where the stack view resizes its arranged views so that they fill the available space along the stack view's axis. Views are resized proportionally based on their intrinsic content size along the stack view's axis.
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.
A streamlined interface for laying out a collection of views in either a column or a row.
You can't do this – UIStackView is a non-drawing view, meaning that drawRect() is never called and its background color is ignored. If you desperately want a background color, consider placing the stack view inside another UIView and giving that view a background color. Reference from HERE.
Remove the constraint on the stack view's bottom edge. Then it will resize to just fit the visible controls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With