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 Cat
with size font 14 and then I change the word to Hippopotamus
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.
A view that displays one or more lines of informational text.
To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.
Set the following properties:
Objective C
label.adjustsFontSizeToFitWidth = NO; label.lineBreakMode = NSLineBreakByTruncatingTail;
Swift
label.adjustsFontSizeToFitWidth = false label.lineBreakMode = .byTruncatingTail
You can also set these properties in interface builder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With