0

This is my first time using MessageKit. I am trying to customize my view but I can't find any helpful information on how to do so like setting insets and changing color of background.

My current layout

I want to start the view from below the title bar and change the background color and the background color of the messages.

func backgroundColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColor {
        return isFromCurrentSender(message: message) ? UIColor.myGold : UIColor.headingGold
    }

Any help will be appreciated.

1 Answers1

5

You have to set contentInset for messagesCollectionView in viewDidLayoutSubviews() to start view below title bar

self.messagesCollectionView.contentInset = UIEdgeInsets(top: title bar height, left: 0, bottom: 70, right: 0)

To set background color of messages you have to use MessagesDisplayDelegate method and delegate, dataSource should be connected with view controller

func backgroundColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColor {
        return isFromCurrentSender(message: message) ? UIColor.blue : UIColor.gray
    }

for more customization you have to check MessageKit example in MessageKit Repo

Kishan Bhatiya
  • 2,175
  • 8
  • 14