Eric Brotto Eric Brotto - 1 year ago 133
Objective-C Question

Getting UILabel to produce an ellipsis rather than shrinking the font

When I dynamically change the text of a UILabel I would prefer to get an ellipsis (dot, dot, dot) rather then have the text be automatically resized. How does one do this?

In other words, if I have UILabel with the word

with size font 14 and then I change the word to
the font shrinks to fit all the word. I would rather the word be automatically truncated followed by an ellipsis.

I assume there is a parameter that can be changed within my UILabel object. I'd rather not do this programmatically.

Answer Source

Set the following properties:

label.adjustsFontSizeToFitWidth = NO;
label.lineBreakMode = NSLineBreakByTruncatingTail;

You can also set these properties in interface builder.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download