iphone - 设置 UIButton 字体

标签 iphone objective-c ios ipad

我有以下用于在 UIButton 中设置文本的代码

[self.fullListButton_ setTitle:[NSString stringWithFormat:@"%d", [self.newsfeedItem_.newsfeedToSubjects count] - 3] forState:UIControlStateNormal];

问题是我似乎无法为此设置字体。我该怎么做?

最佳答案

在较新版本的 iOS 中:

UIButton * myButton;
myButton.titleLabel.font = [UIFont systemFontOfSize: 12];

或任何其他字体机制。

在此处查找 UIButton 部分:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIButton_Class/UIButton/UIButton.html#//apple_ref/occ/instp/UIButton/titleLabel

这里是 UIFont 的东西:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIFont_Class/Reference/Reference.html

在您的代码中:

self.fullListButton_.titleLabel.font = [UIFont systemFontOfSize: 12];

self.fullListButton_.titleLabel.font = [UIFont fontWithName:@"Arial" size:12];

关于iphone - 设置 UIButton 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11443283/

相关文章:

iOS 10 [CFString 发布] : message sent to deallocated instance

iphone - 如何更改占位符文本颜色 - iOS

iphone - NSDateFormatter返回null

objective-c - 像 Numbers 中的标记文本字段

ios - 容器 View 中的 View Controller 与 Objective C 中的父 Controller 之间的交互

iphone - 如何删除 NSArray 中字符串的前导和尾随空格?

ios - 在 Swift 项目中包含基于方案的某些 Objective-C 文件

ios - UILabel 文字划过角度

iphone - Facebook Graph API(向人们介绍我的应用程序)

iOS:为什么没有显示导航栏?