Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between minimumFontSize and minimumScaleFactor in IOS

When I opened a existing project in xcode 7.2, I got a warning saying "minimum font size" is deprecated in ios 6.0.

I have changed it to minimum scale factor.

 labelDescription.numberOfLines  = 2;
 //labelDescription.minimumFontSize=10;       
 labelDescription.minimumScaleFactor = 10;

Does changing the property to minimum scale factor produce the same effect as minimum font size?

like image 224
Yogaraj R Avatar asked Mar 13 '23 15:03

Yogaraj R


2 Answers

Both are the same but the minimumFontSize property of the UILabel is deprecated from iOS 6.0 onwards.

An Alternative to the minimumFontSize is minimumScaleFactor. If you assign minimumFontSize/defaultFontSize to minimumScaleFactor, it works in the same way as minimumFontSize.

The Code is as follows - For Example the font size is 30.0 and if you want the minimum font size to be 12.0

YOURLABEL.font= [UIFont fontWithName:@"FONT_NAME" size:30.0];
[YOURLABEL setMinimumScaleFactor:12.0/[UIFont labelFontSize]];
like image 181
Jigar Avatar answered Apr 09 '23 12:04

Jigar


It produces the same effect, but you need to provide appropriate value for the minimum scale factor.

You should use values between x > 0 && x <= 1. This means if your font is 20, and your scale factor is 0.5, the minimum font size used for scaling will be 10.

like image 40
IxPaka Avatar answered Apr 09 '23 10:04

IxPaka