NIMSessionNetChatNotifyContentView.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // NIMSessionNetChatNotifyContentView.m
  3. // NIMKit
  4. //
  5. // Created by chris on 15/5/8.
  6. // Copyright (c) 2015年 Netease. All rights reserved.
  7. //
  8. #import "NIMSessionNetChatNotifyContentView.h"
  9. #import "M80AttributedLabel+NIMKit.h"
  10. #import "NIMMessageModel.h"
  11. #import "NIMKitUtil.h"
  12. #import "UIView+NIM.h"
  13. #import "NIMKit.h"
  14. @implementation NIMSessionNetChatNotifyContentView
  15. -(instancetype)initSessionMessageContentView
  16. {
  17. if (self = [super initSessionMessageContentView]) {
  18. _textLabel = [[M80AttributedLabel alloc] initWithFrame:CGRectZero];
  19. _textLabel.numberOfLines = 0;
  20. _textLabel.lineBreakMode = NSLineBreakByWordWrapping;
  21. _textLabel.backgroundColor = [UIColor clearColor];
  22. [self addSubview:_textLabel];
  23. }
  24. return self;
  25. }
  26. - (void)refresh:(NIMMessageModel *)data
  27. {
  28. [super refresh:data];
  29. NSString *text = [NIMKitUtil messageTipContent:data.message];
  30. NIMKitSetting *setting = [[NIMKit sharedKit].config setting:data.message];
  31. self.textLabel.textColor = setting.textColor;;
  32. self.textLabel.font = setting.font;
  33. [self.textLabel nim_setText:text];
  34. }
  35. - (void)layoutSubviews{
  36. [super layoutSubviews];
  37. UIEdgeInsets contentInsets = self.model.contentViewInsets;
  38. CGFloat tableViewWidth = self.superview.nim_width;
  39. CGSize contentsize = [self.model contentSize:tableViewWidth];
  40. CGRect labelFrame = CGRectMake(contentInsets.left, contentInsets.top, contentsize.width, contentsize.height);
  41. self.textLabel.frame = labelFrame;
  42. }
  43. @end