Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UILabel truncate text not working

I set the numberOfLines to 1 in the IB, but when I set the text to a long string, it doesn't truncate. If I set the numberOfLines to 2, the truncate works fine.What should I do to truncate a long string into a single line?

like image 776
Eric Qian Avatar asked Dec 10 '12 04:12

Eric Qian


1 Answers

simple, set the following properties:

label.adjustsFontSizeToFitWidth = NO;
label.lineBreakMode = NSLineBreakByTruncatingTail;
like image 200
Asif Mujteba Avatar answered Sep 28 '22 04:09

Asif Mujteba