xcode 在代码中更改标签文本大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7158581/
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-09-09 04:04:48  来源:igfitidea点击:

Changing label text size in code

xcodexcode4

提问by kikovi

I have to adjust my label text size depending of the device (iPad, iPhone) and these orders just doesn't seem to work. I have my label declared in the interface, set on property as IBOutlet and synthesized. Then:

我必须根据设备(iPad、iPhone)调整标签文本大小,而这些命令似乎不起作用。我在界面中声明了我的标签,将属性设置为 IBOutlet 并进行了合成。然后:

label.font = [UIFont fontWithName:@"Arial Black" size:50.0];                    
label.minimumFontSize = 50.0;

The size just doesn't change. :S

大小只是没有改变。:S

Any advices?

有什么建议吗?

回答by Tendulkar

It may be useful to you to use:

使用以下内容可能对您有用:

[label setFont:[UIFont systemFontOfSize:35]];

or

或者

[label setFont: [UIFont fontWithName:@"Arial" size:50.0]];

回答by mayuur

There's nothing wrong in your code except for the font you are using. It should be :

除了您使用的字体外,您的代码没有任何问题。它应该是 :

   label.font = [UIFont fontWithName:@"Arial" size:50];

Actually Arial Blackis not supported by iphone. You can check the list of the fonts supported by iPhone here.

实际上,iPhone 不支持Arial Black。您可以在此处查看iPhone 支持的字体列表。

回答by ChecoSchnaider

You should take a look of the fonts you can use by Default in iOS here is a link: iOS Links http://iosfonts.com/

你应该看看你可以在 iOS 中默认使用的字体,这里是一个链接:iOS 链接http://iosfonts.com/