92

I just upgraded to xcode 4.5 with iOS 6.0 and it's highlighting a warning on all the UILabels in my XIB files saying "minimum font size deprecated on ios version 6.0". Does anyone know what this is referring to and how to fix it?

Update: image is no more available (was at https://skitch.com/hahmadi82/eyk51/cloud)

JOM
  • 8,139
  • 6
  • 78
  • 111
Hooman Ahmadi
  • 1,397
  • 1
  • 12
  • 21
  • not sure how that relates. i was emailed to preview ios6 and xcode 4.5 – Hooman Ahmadi Jun 12 '12 at 22:57
  • rokjarc is right. iOS 6 is still under NDA. Just wait for Apple release notes. – Kimpoy Jun 13 '12 at 00:27
  • 1
    @HoomanAhmadi: all iOS developers got that email. Read the disclamer on the bottom of it: "Pre-release software..." – Rok Jarc Jun 13 '12 at 05:52
  • well i get that. i guess my question is, when the time comes, how will i find out how to solve the warning? will the release notes explain it? – Hooman Ahmadi Jun 13 '12 at 12:15
  • 7
    Change "Minimum Font Size" in the Autoshrink section to "Minimum Font Scale". :p Just had the same problem and came straight here assuming fonts wouldn't violate the NDA. Looks like fonts went through a few changes in the upgrade. – erran Jun 14 '12 at 19:04
  • 18
    I upped this question because it was not correctly closed. At least the reason for closing is wrong wrong wrong. "it is only relevant to a small geographic area" not. It applies to all iOS developers. "extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet" not. It applies to everybody."This question is unlikely to help any future visitors" not. It was incredibly useful to me, and likely to be equally useful to any iOS developers. I understand the NDA issue, but as soon as the NDA is lifted, this question will stand up. – Jean-Denis Muys Jun 17 '12 at 13:44
  • Thanks Jean, I appreciate it. Also, thanks ipwnstuff! – Hooman Ahmadi Jun 18 '12 at 21:13
  • 9
    Folks, the first time I fixed this, I did it manually and it was a special kind of torture. Then I had to merge some changes and thanks to the Xcode beta it gave me emacs as my merge tool so I bailed on that and took the newer version of the file knowing I'd be throwing these away, but then I redid these changes using TextWrangler: the files are xml. Just replace: autoshrinkMode="minimumFontSize" with autoshrinkMode="minimumFontScale" and replace minimumFontSize="10" with minimumFontScale="0.5". Voila. – Rob Jun 22 '12 at 14:29
  • [here's](http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UILabel_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instp/UILabel/minimumFontSize) some documentation on Deprecated UILabel methods. – Spencer Williams Sep 28 '12 at 18:30
  • Google search gives this as top result for "ios6 minimumFontSize" but the stupid moderators policy and the feeleing to abuse the power are closing the important questions. Many questions are top listed and closed by not constructive to localized. If somebody doesn't asking a question with a exception stacktrace than will be closed?! Please repoen it, and fing an answer, I need the solution right now. –  Nov 08 '12 at 16:12
  • @matheszabi - ask and ye shall receive – LittleBobbyTables - Au Revoir Dec 19 '12 at 18:16
  • 1
    @LittleBobbyTables: Would be great if people could ask *nicely*, though. Angry and entitled whining like matheszabi's comment is a great way to convince me to not reopen a question. – C. A. McCann Dec 19 '12 at 18:19
  • No argument here. I can see that my comment could be seen as condoning that sort of rant, although that's certainly not the case; I just wrote matheszabi's comment off as "user is extremely frustrated". Anyways, on with the answers! – LittleBobbyTables - Au Revoir Dec 19 '12 at 18:22
  • 1
    @HoomanAhmadi - can you update your question with a better link? The current image link no longer works. – LittleBobbyTables - Au Revoir Dec 19 '12 at 18:29
  • If any of the below answers presented a solution to your question, please accept their answer by clicking on the check mark beside their answer. This will help future users searching for an answer to the same question. Thank you. – SnareChops Oct 06 '14 at 02:50

9 Answers9

47

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]];
CAMOBAP
  • 5,523
  • 8
  • 58
  • 93
Manju
  • 4,133
  • 2
  • 19
  • 12
19

Use minimumScaleFactor instead... Link

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Aravind NC
  • 762
  • 7
  • 14
8

Quick fix...Here minimum font size to be 8.0

            CGFloat size = textLabel.font.pointSize;// font size of label text
            [textLabel setMinimumScaleFactor:8.0/size];
Sabareesh
  • 3,585
  • 2
  • 24
  • 42
6

I am answering very late, but might help any other. As every one knows that setMinimumFontSize has been deprecated, so other method replacing setMinimumFontSize is setAdjustFontToFitWidth which takes BOOL e.g

[yourLabel setAdjustsFontSizeToFitWidth:YES];
//or
yourLabel.adjustsFontSizeToFitWidth = YES;
Vaibhav Saran
  • 12,848
  • 3
  • 65
  • 75
Syed Ali Salman
  • 2,894
  • 4
  • 33
  • 48
5

For Swift use the following:

//set the number (ex. 8 to your desired minimum font size)
myLabel!.minimumScaleFactor = 8/myLabel!.font.pointSize;`

Works like a charm!

Chris Klingler
  • 5,258
  • 2
  • 37
  • 43
3

I had similar problem. Quick fix is to use MinimumScaleFactor property of UILabel.

Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
1

Go into finder and find the .storyboard file or your .xib and open with TextEdit. Use find to locate the string "autoshrinkMode" and replace the value "minimumFontSize" to "minimumFontScale"

Odd that the conversion wasn't written in the update scripts...

Also credit to @Rob in the comments above for stating the same answer. He should receive credit for this one.

SnareChops
  • 13,175
  • 9
  • 69
  • 91
  • there is no autoshrinkMode in my storyboard file. – Timuçin Apr 14 '13 at 07:37
  • Thanks, this works for me perfectly. @Tim you only have to select the UILabel, and check the "label" option in the right utility panel, and check the options, you will see one called "Autoshrink". http://i.stack.imgur.com/H6YYJ.png – pabloverd Nov 29 '13 at 08:46
0

You can use minimum scale factor over there or drag a lable and set autoshrik-> minimum font.

Maybe this can help you.

shreeji
  • 65
  • 7
0

Yes minumumFontSize is deprecated.

Use following minimumScaleFactor:-

Obj.minimumScaleFactor= (floatValue);
Dharmesh Dhorajiya
  • 3,976
  • 9
  • 30
  • 39
Gaurav
  • 553
  • 5
  • 9