Reputation: 1979
I have a horizontal StackView with distribution as "fill equally". It has 3 labels. I want one of the labels to have dynamic height. When I set the number of number of lines to 0 for that label, it ends up breaking the constraint the spacing constraint at runtime.
All these horizontal stackviews make a one vertical stackview. I have tried setting lower vertical hugging priority and higher resistance priority to the multiline label
Also it behaves like this in the XIB
Before changing the number of lines
After changing the number of lines
Upvotes: 5
Views: 17462
Reputation: 2072
Not Directly answering the question rather on how to control the dynamic height of UIStackView.
now show or hide the contents then Stactview height will dynamically change.
Upvotes: 0
Reputation: 7893
You do not need to set Content Hugging and Compression resistance property to achieve that effect.
Horizontal Stack Views: Set Alignment "Fill" & Distribution "Fill Equally"
Vertical Stack View: Set Alignment "Fill" & Distribution "Fill"
Set Label Lines to 0.
Set Top, Bottom, Leading Constraint for Vertical Stack View.
Upvotes: 7
Reputation: 2962
Set all constraints for UIStackView. Update the UIStackview height constraints constant value based on UILabel text height
Upvotes: 0