最小字体大小在 ios 版本 6.0 上已弃用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11005207/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:45:35  来源:igfitidea点击:

Minimum Font Size deprecated on ios version 6.0

iosxcodeuilabeldeprecatedfont-size

提问by Hooman Ahmadi

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?

我刚刚使用 iOS 6.0 升级到 xcode 4.5,它在我的 XIB 文件中的所有 UILabel 上突出显示了一条警告,说“ios 6.0 版已弃用最小字体大小”。有谁知道这是指什么以及如何解决它?

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

更新:图像不再可用(位于https://skitch.com/hahmadi82/eyk51/cloud

回答by Manju

minimumFontSizeproperty of the UILabelis deprecated from iOS 6.0 onwards.

minimumFontSizeUILabel从 iOS 6.0 开始不推荐使用 的属性。

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

minimumFontSizeis的替代方案minimumScaleFactor。如果分配minimumFontSize/defaultFontSizeminimumScaleFactor,它的工作方式与 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

代码如下 - 例如字体大小为 30.0,如果您希望最小字体大小为 12.0

YOURLABEL.font= [UIFont fontWithName:@"FONT_NAME" size:30.0];
[YOURLABEL setMinimumScaleFactor:12.0/[UIFont labelFontSize]];

回答by Aravind NC

Use minimumScaleFactor instead... Link

使用 minimumScaleFactor 代替... 链接

回答by Sabareesh

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

快速修复...此处最小字体大小为 8.0

            CGFloat size = textLabel.font.pointSize;// font size of label text
            [textLabel setMinimumScaleFactor:8.0/size];

回答by Syed Ali Salman

I am answering very late, but might help any other. As every one knows that setMinimumFontSizehas been deprecated, so other method replacing setMinimumFontSizeis setAdjustFontToFitWidthwhich takes BOOLe.g

我回答得很晚,但可能会帮助其他人。正如每个人都知道setMinimumFontSize已被弃用,因此其他替换方法setMinimumFontSizesetAdjustFontToFitWidth采用BOOL例如

[yourLabel setAdjustsFontSizeToFitWidth:YES];
//or
yourLabel.adjustsFontSizeToFitWidth = YES;

回答by Jayprakash Dubey

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

我有类似的问题。快速修复是使用 UILabel 的 MinimumScaleFactor 属性。

回答by ColossalChris

For Swift use the following:

对于 Swift,请使用以下内容:

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

Works like a charm!

奇迹般有效!

回答by SnareChops

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

进入finder并找到.storyboard文件或您的文件.xib并使用TextEdit打开。使用 find 定位字符串"autoshrinkMode"并将值替换"minimumFontSize""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.

也归功于@Rob 在上面的评论中陈述了相同的答案。他应该为此获得荣誉。

回答by shreeji

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

您可以在那里使用最小比例因子或拖动标签并设置 autoshrik-> 最小字体。

Maybe this can help you.

也许这可以帮助你。

回答by Gaurav

Yes minumumFontSizeis deprecated.

是的minumumFontSize已弃用。

Use following minimumScaleFactor:-

使用以下minimumScaleFactor:-

Obj.minimumScaleFactor= (floatValue);