iOS开源组件__仿写QQ/微信聊天键盘(表情,问题,输入框)纯代码,无依赖
2016-08-25 09:08
489 查看
前言
1.由于项目需求,需要一个类似QQ/微信的聊天键盘,包括语音,emoji和发送图片,文件,位置,网上找了一番,要不功能不够完善,要不依赖太多,于是干脆自己写一个(在使用过程中如果发现什么问题或有什么建议,还望您提出来,共同进步)
2.微信的语音发送实现网上已经很多了,在这里打算做一个QQ语音发送的效果,此模块正在开发中….
DEMO效果
类的介绍
InputToolbar:键盘工具条 VoiceButtonView:语音模块视图 EmojiButtonView:Emoji模块视图 MoreButtonView:加号模块视图(相册,相机,文件,位置...) CollectionViewFlowLayout:表情键盘CollectionView布局 EmpjiCollectionViewCell:表情键盘collectionViewCell UIView+Extension:UIView工具类
集成用法
加头文件: #import "InputToolbar.h" 遵守协议 <MoreButtonViewDelegate,InputToolbarDelegate> 添加属性: @property (nonatomic,strong)InputToolbar *inputToolbar; 创建inputToolbar self.inputToolbar = [InputToolbar shareInstance]; [self.view addSubview:self.inputToolbar]; 输入框最大显示行数 self.inputToolbar.textViewMaxVisibleLine = 4; 布局inputToolbar self.inputToolbar.width = self.view.width; self.inputToolbar.height = 49; self.inputToolbar.y = self.view.height - self.inputToolbar.height; 设定代理 self.inputToolbar.delegate = self; [self.inputToolbar setMorebuttonViewDelegate:self]; 点击发送按钮回调,顺便传回输入内容 __weak typeof(self) weakSelf = self; self.inputToolbar.sendContent = ^(NSObject *content){ NSLog(@"发射成功☀️:---%@",content); if ([content isKindOfClass:[NSTextAttachment class]]) { [weakSelf.textView.textStorage insertAttributedString:[NSAttributedString attributedStringWithAttachment:(NSTextAttachment *)content] atIndex:weakSelf.textView.selectedRange.location]; } else { weakSelf.textView.text = ((NSAttributedString *)content).string; } }; self.inputToolbar.inputToolbarFrameChange = ^(CGFloat height,CGFloat orignY){ _inputToolbarY = orignY; }; 实现协议方法 //在输入的过程中会调用此方法,随着输入框的增高进而调整界面布局 - (void)inputToolbar:(InputToolbar *)inputToolbar orignY:(CGFloat)orignY { _inputToolbarY = orignY; [self.tableView setContentOffset:CGPointMake(0, _tableView.contentSize.height - (0 + orignY + 0)) animated:NO]; } //点击MoreButtonView中的按钮会调用此方法(根据实际需求自行增删) - (void)moreButtonView:(MoreButtonView *)moreButtonView didClickButton:(MoreButtonViewButtonType)buttonType { switch (buttonType) { case MoreButtonViewButtonTypeImages: { //发送相册操作 UIImagePickerController *ipc = [[UIImagePickerController alloc] init]; ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; ipc.delegate = self; [self presentViewController:ipc animated:YES completion:nil]; } break; case MoreButtonViewButtonTypeCamera: { //发送相机操作 UIImagePickerController *ipc = [[UIImagePickerController alloc] init]; ipc.sourceType = UIImagePickerControllerSourceTypeCamera; ipc.delegate = self; [self presentViewController:ipc animated:YES completion:nil]; } break; case MoreButtonViewButtonTypeFile: { //发送文件操作 } break; //....... default: break; } }
Demo下载地址
相关文章推荐
- iOS开源组件__仿写QQ/微信聊天键盘
- ionic在开发ios系统微信时键盘挡住输入框的解决方法(键盘弹出问题)
- iOS中QQ聊天界面发送消息及表情键盘的实现
- ionic在开发ios系统微信时键盘挡住输入框的解决方法(键盘弹出问题)
- 【iOS开发-65】QQ聊天界面案例:自定义cell、图片拉伸处理、NSNotification通知、键盘与视图移动以及输入框左边缩进处理
- iOS开发之优秀开源框架IQKeyboardManager,零行代码解决键盘遮挡问题,如此简单解决键盘遮挡问题,IQKeyboardManager源码分解
- 实现类似QQ、微信聊天界面,标题栏固定,键盘不遮挡底部输入框
- iOS Dev (61) 文本输入框随键盘上移,类似信息、Whatsapp、微信中的聊天输入框
- IOS学习笔记36—解决键盘遮挡输入框(UITextField)问题
- Android UI【android 仿微信、QQ聊天,带表情,可翻页,带翻页拖动缓冲】
- iOS 解决键盘挡住输入框的问题
- iOS 解决键盘挡住输入框的问题
- Android UI【android 仿微信、QQ聊天,带表情,可翻页,带翻页拖动缓冲】
- 仿微信/QQ 开发基于XMPP的iPhone/iOS聊天客户端(二)修改密码
- iOS 解决键盘挡住输入框的问题
- Android UI【android 仿微信、QQ聊天,带表情,可翻页,带翻页拖动缓冲】
- IOS 解决键盘挡住输入框的问题
- IOS学习笔记36—解决键盘遮挡输入框(UITextField)问题
- Android UI【android 仿微信、QQ聊天,带表情,可翻页,带翻页拖动缓冲】
- Android UI【android 仿微信、QQ聊天,带表情,可翻页,带翻页拖动缓冲】