I am building a chat app and I am new to ios, I want to build custom cells like these using messageKIT, can anybody help me with any resource or code?
Asked
Active
Viewed 881 times
0
-
Do you know how to reuse TableViewCells using xib? – Kudos Mar 22 '21 at 13:51
-
Yes, but can I use those with messageKit? – Mohmed Anis Agwan Mar 22 '21 at 13:58
1 Answers
1
Yes, what you want is definitely possible!
You may refer to this GitHub repo that contains a text document/guide on how to configure customs cells with MessageKit
and examples.
An extract from the repo:
Note: If you choose to use the
.custom
kind you are responsible for all of the cell's layout. You can design the cell in code or Interface Builder. AnyUICollectionViewCell
can be returned for custom cells which means any of the styling you provide from theMessageDisplayDelegate
will not affect your custom cell, even if you subclass your cell fromMessageContentCell
.
Creating a custom cell involves four parts:
- Build a cell in Interface Builder or code that inherits from
UICollectionViewCell
- Set the size of your cell. Subclass
MessageSizeCalculator
if you want your cell to have the default MessageKit layout design. SubclassCellSizeCalculator
if you want to further customize your own cell design. The implementation of this class will allow your custom cell to automatically size itself within themessagesCollectionView
.- Add your custom cell size to the collection view flow layout. Subclass
MessagesCollectionViewFlowLayout
, and use the custom message size calculator from step 2, above.- Register your custom cell and reference your custom collection view flow layout.

Asol
- 349
- 3
- 9