Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView cell font size

Tags:

iphone

Is there a way to make the text "automatically" smaller if the text in one row is longer than it can fit?

like image 447
Ali Shafai Avatar asked Dec 17 '22 05:12

Ali Shafai


1 Answers

Yep:

UILabel *myLabel = /* init the label */
myLabel.adjustsFontSizeToFitWidth = YES;

For iOS 7 :

myLabel.minimumScaleFactor = 0.5;  // Float from 0 to 1; as a scale of init size.

For iOS 6 and Prior :

myLabel.minimumFontSize = 10;  // Float value, in pixels (int value recom'd).

You can read more in Apple's UILabel docs.

like image 74
Tyler Avatar answered Jan 01 '23 12:01

Tyler