前言:使用环信UI时需要显示用户的昵称、头像、点击头像进入用户主页。但是有的地方需要直接更改环信UI源码,使用cocoapods误更新环信UI时,源码更改的部分被覆盖。日狗两次,现记录更改流程,以备第三次。。。
1,在EaseMessageViewController.h中添加三个属性
#pragma mark -进入聊天界面时需要的用户昵称,头像,ID @property(nonatomic,strong)NSString*otherUserNick;
@property(nonatomic,strong)NSString*otherUserPic;
@property(nonatomic,strong)NSString*otherUserID;
2,在EaseMessageViewController.m中
- (void)_sendMessage:(EMMessage*)message;方法中增加消息扩展
NSUserDefaults*d = [NSUserDefaultsstandardUserDefaults];
NSMutableDictionary*dic = [NSMutableDictionarydictionaryWithDictionary:message.ext];
dic[@"otherUserId"] =self.otherUserID;
dic[@"otherUserPic"] =self.otherUserPic;
dic[@"otherUserNick"] =self.otherUserNick;
dic[@"userId"] = [dobjectForKey:@"userId"];
dic[@"userPic"] = [dobjectForKey:@"userPic"];
dic[@"userNick"] = [dobjectForKey:@"userNick"];
message.ext= dic;
3,更改聊天气泡的颜色(EaseMessageViewController.m中)
- (void)viewDidLoad ;方法中更改聊天气泡颜色
[[EaseBaseMessageCellappearance]setSendBubbleBackgroundImage:[[UIImageimageNamed:@"bubbleSen"]stretchableImageWithLeftCapWidth:5topCapHeight:35]];
4,隐藏输入框中的录音按钮(EaseChatToolbar.h中)
- (void)_setupSubviews;方法中注释掉
//change input type
UIButton*styleChangeButton = [[UIButtonalloc]init];
styleChangeButton.accessibilityIdentifier=@"style";
styleChangeButton.autoresizingMask=UIViewAutoresizingFlexibleTopMargin;
[styleChangeButtonsetImage:[UIImageeaseImageNamed:@"EaseUIResource.bundle/chatBar_record"]forState:UIControlStateNormal];
[styleChangeButtonsetImage:[UIImageeaseImageNamed:@"EaseUIResource.bundle/chatBar_keyboard"]forState:UIControlStateSelected];
[styleChangeButtonaddTarget:selfaction:@selector(styleButtonAction:)forControlEvents:UIControlEventTouchUpInside];
EaseChatToolbarItem*styleItem = [[EaseChatToolbarItemalloc]initWithButton:styleChangeButtonwithView:nil];
[selfsetInputViewLeftItems:@[styleItem]];
5,修改消息列表中的头像圆角(EaseImageView.h中)
- (void)_setupSubviews;方法中
_imageView.layer.cornerRadius=20;//设置头像圆角 (cell 高度 为 60 减去上下间距20,然后除以2)
网友评论