gpt4 book ai didi

ios - jsqmessagesviewcontroller 链接颜色

转载 作者:搜寻专家 更新时间:2023-10-31 08:25:32 25 4
gpt4 key购买 nike

我正在使用 JSQMessagesViewController,但我希望传出消息为白色。我能够更改文本颜色,因此传出消息文本颜色为黑色,而传入消息文本为白色。但是,无论何时发送链接,在传出端,链接文本仍然是白色的,并且它会融入背景图像中,以至于您看不到它。如何更改链接文本颜色?

最佳答案

在此方法中更改传入文本或传出文本的颜色

    override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

let cell : JSQMessagesCollectionViewCell = super.collectionView(collectionView, cellForItemAtIndexPath: indexPath) as! JSQMessagesCollectionViewCell


let msg : JSQMessage = (self.demoData?.messages[indexPath.row])! as! JSQMessage


if (!msg.isMediaMessage) {

if(msg.senderId == self.senderId())
{
cell.textView?.textColor = UIColor.blackColor() //change this color for your messages
}else
{
cell.textView?.textColor = UIColor.whiteColor() //change this color for other people message
}

cell.textView?.linkTextAttributes = [NSForegroundColorAttributeName : UIColor.blueColor()] //this is the color of the links

}

return cell;

}

使用此代码,您可以更改链接的颜色

        cell.textView?.linkTextAttributes = [NSForegroundColorAttributeName : UIColor.blueColor()] //this is the color of the links

希望对你有帮助

关于ios - jsqmessagesviewcontroller 链接颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38441807/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com