Home > OS >  Swift elements's height in stackview
Swift elements's height in stackview

Time:07-26

I have a stackView like this.enter image description here

If Data has not images image will be hidden. Then label's text is "" , but label's height is to be long. I want label does not fill stackview. How can I do?

CodePudding user response:

A tableview or a collectionview might be more appropriate for UI containers. They are more suitable for a dynamic feature like you mentioned. Having said that you can play with the configuration of the stack view distribution, spacing, and alignment to dynamically set the StackView to accommodate the sizes you wish. In addition to set sizes of subview using - intrinsiccontentsize

Here are two links that can help you with that: UIStackView 1 UIStackView 2 Intrinsiccontentsize

  • Related