ios 设置 UIButton 字体
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11443283/
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 19:13:44 来源:igfitidea点击:
setting UIButton font
提问by xonegirlz
I have the following code for setting up text in a UIButton
我有以下代码用于在 UIButton 中设置文本
[self.fullListButton_ setTitle:[NSString stringWithFormat:@"%d", [self.newsfeedItem_.newsfeedToSubjects count] - 3] forState:UIControlStateNormal];
The issue is I can't seem to set the font for this. How do I do so?
问题是我似乎无法为此设置字体。我该怎么做?
回答by trumpetlicks
In the newer version of iOS:
在较新版本的 iOS 中:
UIButton * myButton;
myButton.titleLabel.font = [UIFont systemFontOfSize: 12];
Or any other font mechanism.
或任何其他字体机制。
Look here for the UIButton portions:
在这里查看 UIButton 部分:
And here for the UIFont stuff:
这里是 UIFont 的东西:
In your code:
在您的代码中:
self.fullListButton_.titleLabel.font = [UIFont systemFontOfSize: 12];
or
或者
self.fullListButton_.titleLabel.font = [UIFont fontWithName:@"Arial" size:12];