ChatKit-OC icon indicating copy to clipboard operation
ChatKit-OC copied to clipboard

关于对话页面头像圆角问题的解决方案

Open kuopenx opened this issue 6 years ago • 1 comments

Base Info for this issue

  1. ChatKit Version:1.0.0
  2. App-ID: XX
  3. Language:Objective-C
  4. iOS System Version:iOS10.3
  5. Prototype(是否是真机):NO
  6. 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

kuopenx avatar Sep 09 '17 08:09 kuopenx

fix in CYLChatKit https://github.com/ChenYilong/CYLChatKit/releases

ChenYilong avatar Jun 14 '18 17:06 ChenYilong