简体   繁体   中英

UILabel not line breaking trailing whitespace

I have a multi line UILabel that I am trying to re-size so it fits the text. This works fine for just text, but I'm also adding in whitespace to give me space to add images in the text. When the text ends with the whitespace for these images, the label doesn't word wrap the whitespace, Here's a couple screenshots, one with just text that is what I'm trying to achieve, and one with images where you can see that the label doesn't wrap to a second line.

在此处输入图片说明在此处输入图片说明

In the second image, the text being assigned to the label is just about 40 spaces, and it won't word wrap, any suggestions on how I can do this?

As maddy mentioned, it's a bad idea to use space for breaking the line.

Using \\n instead of space will give you the desired result.

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