4

I am using JSQMessagesViewController but I want outgoing messages to be white. I was able to change the text color so outgoing message text color is black while incoming message text is white. However, whenever a link is sent, on the outgoing side the link text is still white and it blends into the background image to the point where you can't see it. How do I change link text color?

Jacolack
  • 1,365
  • 2
  • 11
  • 25

1 Answers1

5

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 the links

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

I hope this helps you

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55