当前知识库站点已不再维护。请移步新版知识库:https://help.rongcloud.cn/

自定义聊天界面头像。

需求:想要设置聊天界面的头像为矩形圆角
发布时间: 2015-07-24 11:39

回答:

在聊天界面(继承RCConversationViewController的ViewController)里,实现下面的方法

- (void)willDisplayConversationTableCell:(RCMessageBaseCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    if ([cell isKindOfClass:[RCMessageCell class]]) {
        RCMessageCell *messageCell = (RCMessageCell *)cell;
        //messageCell.portraitImageView
        UIImageView *portraitImageView= (UIImageView *)messageCell.portraitImageView;
        portraitImageView.layer.cornerRadius = 10;
    }
}

在方法里判断如果 cell 是 RCMessageCell,就将 cell 强制转换成 RCMessageCell,然后找到 cell 的 portraitImageView 属性,再强制转换为UIImageView,这样就可以设置圆角的半径了。

5.x 开始 IMKit 开源,建议集成 IMKit 源码,参考对应的实现:https://doc.rongcloud.cn/im/IOS/5.X/ui/import#source