Reputation: 4551
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?
Upvotes: 3
Views: 629
Reputation: 158
Try to select the label, then in attribute inspector set line break to truncate middle
Upvotes: 0
Reputation: 4007
The word you are looking for is "ellipsis" ;)
Set the following properties:
label.adjustsFontSizeToFitWidth = false;
label.lineBreakMode = .byTruncatingMiddle;
You can also set these properties in interface builder.
Example stolen from here: Getting UILabel to produce an ellipsis rather than shrinking the font
UPDATE:
This was deprecated in iOS 6. The current solution would be the slightly modified:
label.adjustsFontSizeToFitWidth = NO;
label.lineBreakMode = NSLineBreakByTruncatingMiddle
Upvotes: 4
Reputation: 6417
@DerekTomes answer in Swift 2.x:
label.adjustsFontSizeToFitWidth = false
label.lineBreakMode = .ByTruncatingMiddle
Upvotes: 0