MessagesDisplayDelegate
public protocol MessagesDisplayDelegate: AnyObject
A protocol used by the MessagesViewController to customize the appearance of a MessageContentCell.
-
messageStyle(for:at:in:)Default implementationSpecifies the
MessageStyleto be used for aMessageContainerView.Note
The default value returned by this method is
MessageStyle.bubble.Default Implementation
Declaration
Swift
func messageStyle(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageStyleParameters
messageThe
MessageTypethat will be displayed by this cell.indexPathThe
IndexPathof the cell.messagesCollectionViewThe
MessagesCollectionViewin which this cell will be displayed. -
backgroundColor(for:at:in:)Default implementationSpecifies the background color of the
MessageContainerView.Note
The default value is
UIColor.clearfor emoji messages. For all otherMessageKindcases, the color depends on theSender.Current sender: Green
All other senders: Gray
Default Implementation
Declaration
Swift
func backgroundColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColorParameters
messageThe
MessageTypethat will be displayed by this cell.indexPathThe
IndexPathof the cell.messagesCollectionViewThe
MessagesCollectionViewin which this cell will be displayed. -
messageHeaderView(for:in:)Default implementationThe section header to use for a given
IndexPath.Default Implementation
Declaration
Swift
func messageHeaderView(for indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageReusableViewParameters
messageThe
MessageTypethat will be displayed for this header.indexPathThe
IndexPathof the header.messagesCollectionViewThe
MessagesCollectionViewin which this header will be displayed. -
messageFooterView(for:in:)Default implementationThe section footer to use for a given
IndexPath.Default Implementation
Declaration
Swift
func messageFooterView(for indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageReusableViewParameters
indexPathThe
IndexPathof the footer.messagesCollectionViewThe
MessagesCollectionViewin which this footer will be displayed. -
configureAvatarView(_:for:at:in:)Default implementationUsed to configure the
AvatarView‘s image in aMessageContentCellclass.Note
The default image configured by this method is
?.Default Implementation
Declaration
Swift
func configureAvatarView(_ avatarView: AvatarView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView)Parameters
avatarViewThe
AvatarViewof the cell.messageThe
MessageTypethat will be displayed by this cell.indexPathThe
IndexPathof the cell.messagesCollectionViewThe
MessagesCollectionViewin which this cell will be displayed.
-
textColor(for:at:in:)Default implementationSpecifies the color of the text for a
TextMessageCell.Note
The default value returned by this method is determined by the messages
Sender.Current sender: UIColor.white
All other senders: UIColor.darkText
Default Implementation
Declaration
Swift
func textColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColorParameters
messageA
MessageTypewith aMessageKindcase of.textto which the color will apply.indexPathThe
IndexPathof the cell.messagesCollectionViewThe
MessagesCollectionViewin which this cell will be displayed. -
enabledDetectors(for:at:in:)Default implementationSpecifies the
DetectorTypes to check for theMessageType‘s text against.Note
This method returns an empty array by default.
Default Implementation
Declaration
Swift
func enabledDetectors(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> [DetectorType]Parameters
messageA
MessageTypewith aMessageKindcase of.textor.attributedTextto which the detectors will apply.indexPathThe
IndexPathof the cell.messagesCollectionViewThe
MessagesCollectionViewin which this cell will be displayed. -
detectorAttributes(for:and:at:)Default implementationSpecifies the attributes for a given
DetectorTypeDefault Implementation
Declaration
Swift
func detectorAttributes(for detector: DetectorType, and message: MessageType, at indexPath: IndexPath) -> [NSAttributedStringKey: Any]Parameters
detectorThe
DetectorTypefor the applied attributes.messageA
MessageTypewith aMessageKindcase of.textor.attributedTextto which the detectors will apply.indexPathThe
IndexPathof the cell.
-
snapshotOptionsForLocation(message:at:in:)Default implementationUsed to configure a
LocationMessageSnapshotOptionsinstance to customize the map image on the given location message.Default Implementation
Declaration
Swift
func snapshotOptionsForLocation(message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> LocationMessageSnapshotOptionsParameters
messageA
MessageTypewith aMessageKindcase of.location.indexPathThe
IndexPathof the cell.messagesCollectionViewThe
MessagesCollectionViewrequesting the information.Return Value
The LocationMessageSnapshotOptions instance with the options to customize map style.
-
annotationViewForLocation(message:at:in:)Default implementationUsed to configure the annoation view of the map image on the given location message.
Default Implementation
Declaration
Swift
func annotationViewForLocation(message: MessageType, at indexPath: IndexPath, in messageCollectionView: MessagesCollectionView) -> MKAnnotationView?Parameters
messageA
MessageTypewith aMessageKindcase of.location.indexPathThe
IndexPathof the cell.messagesCollectionViewThe
MessagesCollectionViewrequesting the information.Return Value
The
MKAnnotationViewto use as the annotation view. -
animationBlockForLocation(message:at:in:)Default implementationAsk the delegate for a custom animation block to run when whe map screenshot is ready to be displaied in the given location message. The animation block is called with the
UIImageViewto be animated.Default Implementation
Declaration
Swift
func animationBlockForLocation(message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> ((UIImageView) -> Void)?Parameters
messageA
MessageTypewith aMessageKindcase of.location.indexPathThe
IndexPathof the cell.messagesCollectionViewThe
MessagesCollectionViewrequesting the information.Return Value
The animation block to use to apply the location image.
-
configureMediaMessageImageView(_:for:at:in:)Default implementationUsed to configure the
UIImageViewof a `MediaMessageCell.Default Implementation
Declaration
Swift
func configureMediaMessageImageView(_ imageView: UIImageView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView)Parameters
imageViewThe
UIImageViewof the cell.messageThe
MessageTypethat will be displayed by this cell.indexPathThe
IndexPathof the cell.messagesCollectionViewThe
MessagesCollectionViewin which this cell will be displayed.
MessagesDisplayDelegate Protocol Reference