【发布时间】:2015-07-08 09:22:16
【问题描述】:
我不得不说我对 Swift 还很陌生,我一直在设置 NSMutableAttributedString 中的 UILabel。
var attributedString = NSMutableAttributedString("random string for this example")
attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: NSMakeRange(1, 3))
tweetTextLabel?.text = attributedString
最后一行给了我:'_ ??' is not convertible to '()',所以我什至无法编译。
我也试过:
tweetTextLabel?.text = attributedString.string
但是这样我就失去了颜色属性
【问题讨论】:
-
tweetTextLabel?.attributedText = attributedString -
非常感谢,我没有注意到UILabel中的那个方法