You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The basics of message cells and a guide on customizing them.
Guide & Snippet
You can customize the message cells by inheritting different Sendbird UIKit message cells. You can selectively override the components, methods, and/or add custom views into the existing view hierarchy.
Each message cell (SBUUserMessageCell, SBUFileMessageCell, SBUMultipleFilesMessageCell, SBUAdminMessageCell, SBUTypingIndicatorMessageCell) inherits SBUContentBaseMessageCell. To add your custom views into the existing message cells, you can selectively insert views into the view hierarchy of SBUContentBaseMessageCell or that of each message cell. The below is an image of the view hierarchy of SBUContentBaseMessageCell.
The code below shows an example of adding a UILabel view into SBUUserMessageCell.
classMyUserMessageCell:SBUUserMessageCell{// The custom view to be added to SBUUserMessageCell
lazy varmyLabel:UILabel={letlabel=UILabel()
label.textColor =.systemBlue
label.font =.systemFont(ofSize:14)
label.numberOfLines =0return label
}()overridefunc setupViews(){
super.setupViews()// Insert myLabel view inside mainContainerView of SBUUserMessageCell.self.mainContainerView.addArrangedSubview(myLabel)}overridefunc configure(with configuration:SBUBaseMessageCellParams){
super.configure(with: configuration)
guard let configuration = configuration as?SBUUserMessageCellParamselse{return}
guard let userMessage = configuration.userMessage else{return}
myLabel.text ={YOUR_DATA}}}// Register the custom message cell before presenting the group channel view controller.
groupChannelVC.listComponent?.register(userMessageCell:MyUserMessageCell())
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
The basics of message cells and a guide on customizing them.
Guide & Snippet
You can customize the message cells by inheritting different Sendbird UIKit message cells. You can selectively override the components, methods, and/or add custom views into the existing view hierarchy.
Each message cell (
SBUUserMessageCell
,SBUFileMessageCell
,SBUMultipleFilesMessageCell
,SBUAdminMessageCell
,SBUTypingIndicatorMessageCell
) inheritsSBUContentBaseMessageCell
. To add your custom views into the existing message cells, you can selectively insert views into the view hierarchy ofSBUContentBaseMessageCell
or that of each message cell. The below is an image of the view hierarchy ofSBUContentBaseMessageCell
.The code below shows an example of adding a UILabel view into
SBUUserMessageCell
.Reference
Beta Was this translation helpful? Give feedback.
All reactions