[英]NSMutableAttributedString contains NSMutableAttributedString and NSString
[英]'_ ??' is not convertible to '()' with NSMutableAttributedString
我要說的是,我對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
最后一行給我: '_ ??' is not convertible to '()'
'_ ??' is not convertible to '()'
所以我什'_ ??' is not convertible to '()'
無法編譯。
我也嘗試過:
tweetTextLabel?.text = attributedString.string
但是這樣我就失去了color屬性
您應該設置為UILabel
的attributedText
屬性,例如:
tweetTextLabel?.attributedText = attributedString
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.