我不得不说我是 Swift 的新手,我一直坚持在 UILabel
中设置 NSMutableAttributedString
。
var attributedString = NSMutableAttributedString("random string for this example")
attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: NSMakeRange(1, 3))
tweetTextLabel?.text = attributedString
最后一行给我:'_ ??'不能转换为“()”
,所以我什至无法编译。
我也试过:
tweetTextLabel?.text = attributedString.string
但是这样我就失去了颜色属性
最佳答案
您应该设置为 UILabel
的 attributedText
属性,例如:
tweetTextLabel?.attributedText = attributedString
关于ios - '_? ?' is not convertible to ' ()' 与 NSMutableAttributedString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31288494/