Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIStackView Distribution Fill Equally

So, I have a UIStackView that contains four (4) UIViews. If I remove one (1) of those UIViews, 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.

like image 818
Bnj Avatar asked Oct 26 '16 06:10

Bnj


People also ask

What is fill proportionally in UIStackView?

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.

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 UIStackView?

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

How can I change background color in Stackview?

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.


1 Answers

Remove the constraint on the stack view's bottom edge. Then it will resize to just fit the visible controls.

like image 142
phatmann Avatar answered Oct 26 '22 23:10

phatmann