Nir Tzezana
Nir Tzezana

Reputation: 2342

UILabel text breaks single word by character when it should break by word

I have this xib file which has 3 labels.
I need the labels to act as a table header, which means the labels line property is set to 0 and the line break property set to word wrap.

This sounds promising, but it breaks single words by character and if the label has more than one word it shows the first word only.

I have tried anything I can think about, and am trying to stay in the XCODE editor and write code as little as possible.

Edit: The behaviour I'm aiming at is this:
If it's a single word and won't fit inside the designated area: make the text smaller.
If it's more than one word, break the phrase but never break a word by character.

Here's an image of my xib file.

My xib

As you can see, the single word (encyclopedia) is broken into 2 lines.

Upvotes: 1

Views: 944

Answers (1)

il3v
il3v

Reputation: 512

It's acting as expected: "Wrapping occurs at word boundaries, unless the word itself doesn’t fit on a single line." (source)

Upvotes: 1

Related Questions