我可以设置`UILabel`的`attributedText`属性 [英] Can I set the `attributedText` property of `UILabel`
本文介绍了我可以设置`UILabel`的`attributedText`属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以设置 UILabel
对象的 attributedText
属性吗?我尝试了以下代码:
Can I set the attributedText
property of a UILabel
object? I tried the below code:
UILabel *label = [[UILabel alloc] init];
label.attributedText = @"asdf";
但它会出现此错误:
在'UILabel *'类型的对象上找不到属性attributedText
Property "attributedText" not found on object of type 'UILabel *'
#import< CoreText / CoreText.h>
无法正常工作
推荐答案
不幸的是,您可以使用 OHAttributedLabel 代替。 UILabel
不支持属性字符串。
Unfortunately, You can use OHAttributedLabel instead.UILabel
doesn't support attributed strings.
更新:自iOS6起, UILabel
支持归因于字符串参见 UILabel参考或Michael Kessler在下面的回答了解更多细节。
Update: Since iOS6, UILabel
does support attributed strings. See UILabel reference or Michael Kessler's answer below for more details.
这篇关于我可以设置`UILabel`的`attributedText`属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文