2

I am using JSQMessageViewControllers library to implement the chat view. However, I want to hide the avatar image in the chat.

According to the following documentation. http://cocoadocs.org/docsets/JSQMessagesViewController/7.2.0/Protocols/JSQMessagesCollectionViewDataSource.html#//api/name/collectionView:avatarImageDataForItemAtIndexPath:

I will just need to return nil in the following function.

override func collectionView(collectionView: JSQMessagesCollectionView!, avatarImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageAvatarImageDataSource! {
    return nil
}

However, after returning nil. It has white spaces for each message for the original avatar location. chat image

How can we remove the white spaces?

howly
  • 417
  • 1
  • 3
  • 12

2 Answers2

6

I solved the problem by setting the following properties in my JSQMessageViewController subclass to remove the white spaces.

collectionView?.collectionViewLayout.incomingAvatarViewSize = CGSizeZero
collectionView?.collectionViewLayout.outgoingAvatarViewSize = CGSizeZero
howly
  • 417
  • 1
  • 3
  • 12
1

In the view did load setting

collectionView?.collectionViewLayout.incomingAvatarViewSize = .zero collectionView?.collectionViewLayout.outgoingAvatarViewSize = .zero .zero comes form CoreGraphics CGSize

Dan Leonard
  • 3,325
  • 1
  • 20
  • 32