【发布时间】:2013-03-07 13:37:27
【问题描述】:
我正在尝试使用TTTAttributedLabel 使用以下代码为标签添加下划线:
[self.opponentUsername setText:self.opponentUsername.text afterInheritingLabelAttributesAndConfiguringWithBlock:^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
[mutableAttributedString addAttribute:(NSString *)kCTUnderlineStyleAttributeName value:[NSNumber numberWithInt:1] range:(NSRange){0, [mutableAttributedString length]}];
return mutableAttributedString;
}];
在 Interface Builder 中禁用 Autoshrink 时它可以正常工作。但是,一旦我启用 Autoshrink,标签就会失去我在 IB 中应用的白色,并且下划线完全消失。
我在这里做错了什么? TIA
仅供参考,提供使用TTTAttributedLabel 以外的一些自定义库的解决方案的答案也很好。
【问题讨论】:
标签: ios cocoa-touch nsattributedstring