Reputation: 4705
Why would I need contraints on elements that live inside my stack view? Is not the idea of the Stack View to stack elements automatically thus making the need of explicit measures to be added?
Upvotes: 2
Views: 770
Reputation: 5130
Well Said. Stackview
get its height and width from content size
.
Sometime we cannot say exactly how much content size
a ui element
has.
For example if we have an imageview
inside stackview
and we assign image
at runtime. The stackview
will grow with the imageview
. The question is how much. Well it depends on the size of image. So there we can feel undesired results. So we fix stackview
size using predefined constraints
.
Also, Stackview
need constraints
for position. Where to position stackview
inside view of viewcontroller
. So we need constraints
for positioning our stackview
.
Upvotes: 4