简体   繁体   中英

ios - UIStackView and multiline UILabels

I'm trying to put multiline UILabels into the vertical UIStackView and then put this UIStackView into the horizontal UIStackView alongside other views ( UIImage and UIButton ).

My problem is that number of lines of the label is always one. Is it possible to force the label become multiline without specifying the width of the vertical stack?

Want to implement something like this: 在此处输入图像描述

Of course you can do that...

在此处输入图像描述

"Outer" horizontal stack view:

在此处输入图像描述

"Inner" vertical stack view:

在此处输入图像描述

Is it possible to force the label become multiline without specifying the width of the vertical stack?

No, the base behind wrapping is a specified width (static/proportional), so you should either set a width for the vertical stack or the label

I am not 100% sure of what you are trying to achieve. But from what I understand, when vertical stack view is embedded again in the horizontal stack View. The horizontal stackView property along with its constraints determine how to set up the position specially stackView alignment and distribution.Even inside the stack view you can set your label to width to be of maximum constant. As I am not sure of the exact scenario, maybe you could simply add a line break \n to your UILabel text.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM