Hi! So sorry for the flurry of questions asked by myself recently. I had another question/issue about resizing the avatarView. So currently, I am using these two methods:
func avatarPosition(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> AvatarPosition {
return AvatarPosition(horizontal: .natural, vertical: .messageCenter)
}
func avatarSize(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> CGSize {
return CGSize(width: 50, height: 50)
}
But for some reason, these avatars are not being positioned at the center of the message vertically- they remain at the bottom. Also the size adjustment code isn't changing the size of the avatar, even when I set it to something obscene, like 100. Is there some other method I am missing?
That method was removed in 1.0. Adjust the MessageSizeCalculators in the MessagesCollectionViewLayout
Sent with GitHawk
How can I remove the AvatarView from the cell?
You can set the AvatarView to hidden through the configureAvatarView(_:AvatarView,for:MessageType,at:IndexPath,in:MessagesCollectionView) method of MessagesDisplayDelegate.
func configureAvatarView(_ avatarView: AvatarView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) {
avatarView.isHidden = true
}
If you would also like to remove the space the AvatarView occupies, you have to change the properties
outgoingAvatarSize or incomingAvatarSize of the CellSizeCalculator object for the respective message to CGSize.zero in
viewDidLoad.
if let layout = messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout {
layout.textMessageSizeCalculator.outgoingAvatarSize = .zero
layout.textMessageSizeCalculator.incomingAvatarSize = .zero
}
If you would like to remove the space the AvatarView occupies from all CellSizeCalculators there are
convenience methods so that you do not have to specify it for each CellSizeCalculator on MessagesCollectionViewFlowLayout.
if let layout = messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout {
layout.setMessageIncomingAvatarSize(.zero)
layout.setMessageOutgoingAvatarSize(.zero)
}
This issue has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This issue has been auto-closed because there hasn't been any activity for at least 21 days. However, we really appreciate your contribution, so thank you for that! 馃檹 Also, feel free to open a new issue if you still experience this problem 馃憤.
Most helpful comment
How can I remove the
AvatarViewfrom the cell?You can set the
AvatarViewto hidden through theconfigureAvatarView(_:AvatarView,for:MessageType,at:IndexPath,in:MessagesCollectionView)method ofMessagesDisplayDelegate.If you would also like to remove the space the
AvatarViewoccupies, you have to change the propertiesoutgoingAvatarSizeorincomingAvatarSizeof theCellSizeCalculatorobject for the respective message toCGSize.zeroinviewDidLoad.If you would like to remove the space the
AvatarViewoccupies from allCellSizeCalculators there areconvenience methods so that you do not have to specify it for each
CellSizeCalculatoronMessagesCollectionViewFlowLayout.