samir samir - 4 months ago 15
Objective-C Question

UILabel Truncation

I have text like this: "My text is blabla blabla, lala lala ".

I would like to have the text in my

UILabel
like this: "My text is ...lala".

How can I configure my
UILabel
to display the text to have the ellipsis in the middle?

Answer

The word you are looking for is "ellipsis" ;)

Set the following properties:

label.adjustsFontSizeToFitWidth = NO;
label.lineBreakMode = UILineBreakModeMiddleTruncation;

You can also set these properties in interface builder.

Example stolen from here: Getting UILabel to produce an ellipsis rather then shrinking the font

Comments