Link color jsqmessagesviewcontroller

I am using JSQMessagesViewController but want outgoing messages to be white. I was able to change the color of the text, so the text color of the outgoing message is black, and the text of the incoming message is white. However, whenever the link is sent, on the outgoing side, the link text is still white, and it mixes with the background image to the place where you do not see it. How to change the color of link text?

+4
source share
1 answer

In this method, change the color of the incoming text or outgoing text

    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;

}

with this code you can change the color of links

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

Hope this helps you.

+5
source

Source: https://habr.com/ru/post/1648278/


All Articles