0
votes

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.

enter image description hereenter image description here

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?

1
Don't use spaces. Use an appropriate number of newlines (\n), one for each line. - rmaddy
Do you have any suggestions on how I can calculate where to put the \n? The label needs to fit the text with a max width of 250 but the text it contains could be any combination of text and whitespaces so it won't always be the same number of characters per line. - SeanT
You want yout label to fit screen width right? Use auto-layout constraint then. - orkenstein

1 Answers

0
votes

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.