我正在尝试使用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
也很好。