最近在做一個半屏聊天的功能,類似映客是私信.在網(wǎng)上找了半天沒有找到相關的資料,在這里記錄下給大家提供點思路.
本帖子是基于融云的聊天界面,環(huán)信還沒驗證,想來也差不多.廢話不多說直接來干貨.

需求圖片
1.先說下思路
聊天界面 View 是全屏的 View ,只是把上面放聊天的 collectionView 縮小就可以了.在上邊空白處放一個 button , 點擊銷毀聊天視圖.
2.具體實現(xiàn)
.h文件中直接繼承融云視圖
@interface WKSmallChatViewController : RCConversationViewController
@end
.m文件中設置 collectionView 高度
@implementation WKSmallChatViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor clearColor];//背景設透明
CGFloat height;//橫豎屏高度
if (WKScreenW>WKScreenH) {
height = WKScreenH;
}else{
height = 420;
}
//設置高度
[self.conversationMessageCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_offset(0);
make.bottom.mas_offset(60);
make.width.mas_offset(WKScreenW);
make.height.mas_offset(height);
}];
}