[英]'_ ??' is not convertible to '()' with NSMutableAttributedString
I've to say that i'm pretty new to Swift and i'm stuck in setting a NSMutableAttributedString
in a UILabel
. 我要说的是,我对Swift还是很NSMutableAttributedString
,并且在UILabel
中设置NSMutableAttributedString
很UILabel
。
var attributedString = NSMutableAttributedString("random string for this example")
attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: NSMakeRange(1, 3))
tweetTextLabel?.text = attributedString
The last line gives to me: '_ ??' is not convertible to '()'
最后一行给我: '_ ??' is not convertible to '()'
'_ ??' is not convertible to '()'
so I can't even compile. '_ ??' is not convertible to '()'
所以我什'_ ??' is not convertible to '()'
无法编译。
I tried also with: 我也尝试过:
tweetTextLabel?.text = attributedString.string
but in this way I lose the color attribute 但是这样我就失去了color属性
您应该设置为UILabel
的attributedText
属性,例如:
tweetTextLabel?.attributedText = attributedString
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.