这是我第一次使用MessageKit。我正在尝试自定义视图,但找不到任何有用的信息,例如设置插图和更改背景颜色。
我想从标题栏下面开始查看,并更改背景颜色和消息的背景颜色。
func backgroundColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColor {
return isFromCurrentSender(message: message) ? UIColor.myGold : UIColor.headingGold
}
任何帮助将不胜感激。
答案 0 :(得分:2)
您必须为contentInset
中的messagesCollectionView
设置viewDidLayoutSubviews()
才能在标题栏下方开始查看
self.messagesCollectionView.contentInset = UIEdgeInsets(top: title bar height, left: 0, bottom: 70, right: 0)
要设置消息的背景色,您必须使用MessagesDisplayDelegate
方法和委托,dataSource应该与视图控制器连接
func backgroundColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColor {
return isFromCurrentSender(message: message) ? UIColor.blue : UIColor.gray
}
要进行更多自定义,您必须查看MessageKit
回购中的MessageKit
示例