关于对话页面头像圆角问题的解决方案
kuopenx opened this issue · comments
Base Info for this issue
- ChatKit Version:1.0.0
- App-ID: XX
- Language:Objective-C
- iOS System Version:iOS10.3
- Prototype(是否是真机):NO
- Issue Type:Bug
1. How to repeat the problem.
1)已经设置了头像圆角的block方法,可是运行时发现在对话页面头像圆角并没有生效,但是经过再次刷新cell(拖到屏幕外再松手)圆角会生效,最近联系人页面的头像没有这个问题。
2)再就是chatkit内部设置的圆角方法回导致刷新页面时图片出现闪动(体验不是很好,但还可以接受),提一下
3)_avatarImageView.contentMode = UIViewContentModeScaleAspectFill;//防止特别长或者宽的图片显示不正常,防止图像太长会超出bounds,建议设置成此样式
2. Please help me in this way.
发现问题所在是头像设置圆角有个前提:frame不能是0,在设置了frame之后,圆角才能生效,亲测有效,可以在设置圆角代码前加上一句设置imageView.frame = CGRectMake(0, 0, 50, 50);
3. Here is a Demo.
- (UIImageView *)avatarImageView {
if (!_avatarImageView) {
_avatarImageView = [[UIImageView alloc] init];
// _avatarImageView.contentMode = UIViewContentModeScaleAspectFit;
_avatarImageView.contentMode = UIViewContentModeScaleAspectFill;//防止特别长或者宽的图片显示不正常
LCCKAvatarImageViewCornerRadiusBlock avatarImageViewCornerRadiusBlock = [LCChatKit sharedInstance].avatarImageViewCornerRadiusBlock;
if (avatarImageViewCornerRadiusBlock) {
CGSize avatarImageViewSize = CGSizeMake(kAvatarImageViewWidth, kAvatarImageViewHeight);
CGFloat avatarImageViewCornerRadius = avatarImageViewCornerRadiusBlock(avatarImageViewSize);
// self.avatarImageView.lcck_cornerRadius = avatarImageViewCornerRadius;
_avatarImageView.frame = CGRectMake(0, 0, kAvatarImageViewWidth, kAvatarImageViewHeight);//这一句代码是我后来加上的,可以使圆角立刻生效
_avatarImageView.lcck_cornerRadius = avatarImageViewCornerRadius;
}
[self bringSubviewToFront:_avatarImageView];
}
return _avatarImageView;
4. Here is my Debug log
fix in CYLChatKit https://github.com/ChenYilong/CYLChatKit/releases