Reputation: 9586
I would like to display "..." at the end of the UILabel when a word is too large rather than simply truncating it as shown below.
For example in the image below the entry n. 2 (Minecraft) should display "..." at the end of the word Edition (like this: Edit...) and not truncate the word (like you can see below: Editio).
In the image you should be able to see the label options I set.
I tried to modify the line break value but I think is not the right approach.
Any suggestions?
Upvotes: 1
Views: 2804
Reputation: 46
I think you need to add a width constraint to your UILabel if you're using Auto Layout. If not, just try to decrease the UILabel width.
Upvotes: 1
Reputation: 139
Just decrease the label width that can display up to Edit...
set following values in Attribute Inspector
Lines set to 1
Line Breaks set to Truncate Trail
It works in my case
Upvotes: 0
Reputation: 7704
Set line break mode to NSLineBreakByTruncatingTail
(which you have set properly in NIB: Line Breaks = Truncate Tail).)
And in Auto layout, make sure your label never goes outside cell.
I expect your label is sizing itself automatically meaning if the text is too long, it just goes outside cell bounds. Add constraint "Trailing Space to superview" to label with value "is greater than N" (e.g. "> 15"). Using this, your label will never go outside bounds of superview and rather cut-off itself with "..." at the end as you want.
Upvotes: 1