【发布时间】:2013-08-14 14:41:16
【问题描述】:
我正在尝试在自定义 UIButton 上为我的标题添加下划线,但按照找到的示例 here,我无法让它显示在屏幕上。
这是我尝试使用的代码:
NSMutableAttributedString *commentString = [[NSMutableAttributedString alloc] initWithString:@"The Quick Brown Fox"];
[commentString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [commentString length])];
[button setAttributedTitle:commentString forState:UIControlStateNormal];
这不显示。但如果我只是做一个普通的,像这样:
[button setTitle:@"The Quick Brown Fox" forState:UIControlStateNormal];
这显示得很好。谁能告诉我我错过了什么?
【问题讨论】:
-
我的回答不正确,所以我删除了它。您的目标是哪个版本的 iOS?
-
@Firo iOS 6.0 或更高版本
标签: objective-c ios6 uibutton nsattributedstring