我的代码在雨燕1.2工作得很好,但在斯威夫特2我收到此错误:错误:“无法将类型为String:UIColor?的值分配给类型为String:AnyObject的值!”
Cannot assign a value of type String: UIColor? to a value of type String: AnyObject!
我的代码是:
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = super.collectionView(collectionView, cellForItemAtIndexPath: indexPath) as! JSQMessagesCollectionViewCell
let message = messages[indexPath.row]
if message.senderId == self.senderId {
cell.textView!.textColor = UIColor.blackColor()
} else {
cell.textView!.textColor = UIColor.whiteColor()
}
// Error in the following line
cell.textView!.linkTextAttributes = [NSForegroundColorAttributeName:cell.textView!.textColor]
return cell
}
感谢的人!它的工作:)。对不起,我不能投票回答你的答案,因为我是新来的,我没有足够的声望(至少需要15个)。 –
你可以投我的问题,我会得到10个声望(我认为),我已经有5个 –