Boon Boon - 9 months ago 221
iOS Question

Multiline label in UIStackView

When putting multiline label (with linebreak set to Word Wrap) into a stack view, the label immediately loses the linebreak and displays the label text in one line instead.

Why is this happening and how does one preserve multiline label within a stack view?

  • First set the label number of lines to 0
  • The stackview still won't grow to multiLine unless you give a fixed width to stackview. When we fixed the width of stackview Then it break to multiline when that width is reached as shown:

enter image description here

If we don't give a fixed width to stackview then things get ambiguous. How long will stackview grow with label(If label value is dynamic).

That's why we give a fixed width to stackview.

Hope this can fix your issue.