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
Changing label text size in code
提问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 支持的字体列表。