I need to do some special alignment with a UILabel.
I want it to have 1 to 3 lines, whatever content it has.
Currently I'm doing it something like this:
label.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:14.0f]; label.backgroundColor = [UIColor clearColor]; label.numberOfLines = 0; label.lineBreakMode = UILineBreakModeWordWrap; label.frame = CGRectMake(114.0f, 88.0f, 187.0f, 0.0f); [label sizeToFit];
which works great if the text is not too long. if the string is something like @"Hello World"
the UILabel is only 14 points high, if it is some way longer it expands.
Now I want that the text should add it's default ...
triple dots if the text gets too long for three lines, but with the setting on top it expands to the fourth line.
How do I achieve this?
"Short answer: you can't. To change the spacing between lines of text, you will have to subclass UILabel and roll your own drawTextInRect, or create multiple labels."
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.
A view that displays one or more lines of informational text.
Just set label.numberOfLines = 3;
.
It is somewhat mislabeled, as it actually holds the maximum amount of lines to display.
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