iOS自定义聊天消息页面
2018-02-02 16:41
621 查看
简单的消息聊天界面,低耦合,无依赖,修改简单
项目地址 https://github.com/DYLAN-LWB/WBChatView
项目地址 https://github.com/DYLAN-LWB/WBChatView
#import "ViewController.h" #import "WBChatView.h" @interface ViewController () <WBChatViewDelegate> @property (nonatomic, strong) WBChatView *chatView; @property (nonatomic, strong) NSMutableArray *chatMsg; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor lightGrayColor]; self.chatMsg = [NSMutableArray array]; self.chatView = [[WBChatView alloc] init]; self.chatView.frame = CGRectMake(0, SCREEN_HEIGHT - 500, SCREEN_WIDTH, 500); self.chatView.backgroundColor = [UIColor redColor]; self.chatView.delegate = self; [self.view addSubview:self.chatView]; [self addMessage:MsgTypeIsText form:MsgFromIsLeft text:@"简单的聊天界面,低耦合,无依赖,修改简单"]; [self addMessage:MsgTypeIsText form:MsgFromIsLeft text:@"1.0版本只有文字消息\n后续会加入输入框自适应高度,图片消息,语音消息,等等"]; } //delegate - (void)sendMessage:(NSInteger)type text:(NSString *)text { [self addMessage:MsgTypeIsText form:MsgFromIsRight text:text]; } //新增消息 - (void)addMessage:(NSInteger)type form:(NSInteger)form text:(NSString *)text { WBChatModel *msgModel = [[WBChatModel alloc] init]; msgModel.msgType = type; msgModel.msgFrom = form; msgModel.msgText = text; [self.chatMsg addObject:msgModel]; self.chatView.chatMsg = self.chatMsg; }
相关文章推荐
- ios 开发之 -- 极光推送,发送自定义消息,进入制定页面
- iOS极光推送 点击推送消息跳转页面
- iOS点击推送消息跳到应用指定页面方法
- iOS收到推送消息后跳到指定的页面
- ios IM 基于环信的自定义聊天界面
- iOS极光推送 点击推送消息跳转页面
- ios环信-由自定义列表获取群组聊天窗体
- iOS开发系列之常用自定义控件开发集—自定义状态栏消息提示控件开发
- iOS极光推送之自定义消息
- iOS极光推送 点击推送消息跳转页面
- iOS极光推送 点击推送消息跳转页面
- iOS学习笔记之远程推送、静默推送与自定义消息推送
- 自定义iOS 中推送消息 提示框
- iOS页面间传递消息之Delegate
- 简易聊天程序教程(一)自定义异常和消息格式
- iOS极光推送 点击推送消息跳转页面
- iOS自定义推送消息提示框
- iOS 为自定义返回按钮的页面添加右滑返回
- iOS 点击推送消息跳到应用指定页面的实例
- ios极光推送的自定义消息和registerID的获取