Chatto
Chatto copied to clipboard
Circle User Avatar
I Install Chatto with Pods :
pod 'Chatto', '~> 3.0.1' pod 'ChattoAdditions', '~> 3.0.1'
I need UserAvatar imageview show circle ? Witch class must be override ? Thanks
I also need circle avatarView. How to access to avatarView when using your ChattoAdditions
?
I don't know if it's the right place but modifying layoutSubViews() in BaseMessageCollectionViewCell.swift with:
self.avatarView.layer.cornerRadius = self.avatarView.frame.size.width / 2
self.avatarView.clipsToBounds = true
below the self.avatarView.bma_rect = layoutModel.avatarViewFrame
line, works.
A hack that we've come up with in our project is to render a new UIImage
with rounded edges and use that as the avatar image.
However, we'd prefer to have a proper solution where it's possible to set the cornerRadius
on the UIImageView
extension UIImage {
func createRoundedImage() -> UIImage {
let imageLayer = CALayer()
imageLayer.frame = CGRect(x: 0.0, y: 0.0, w: self.size.width, h: self.size.height)
imageLayer.contents = self.cgImage
imageLayer.masksToBounds = true
imageLayer.cornerRadius = self.size.width / 2
UIGraphicsBeginImageContext(self.size)
imageLayer.render(in: UIGraphicsGetCurrentContext()!)
let roundedImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return roundedImage!
}
}
I agree with @LukA888 , then we need to add property like avatarStyle
on BaseMessageViewModel
, and able to use like below.
viewModel.avatarStyle = .circle
viewModel.avatarStyle = .square
enum AvatarStyle {
case .circle
case .square
}
So, I'll start to make PR for Chatto.
Hi @d-date ! Have you done PR for this rounding?
@alexsanderkhitev Afraid not, but I found that we shouldn't customize cells using this repo. I think this repo is needed for easy to construct chat UI, without customizability. so try to consider to create your own cell:)
@d-date thank you for response!
Any news in new release about circle avatar?