NTESSessionWhiteBoardContentView.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // NTESSessionWhiteBoardContentView.m
  3. // NIM
  4. //
  5. // Created by chris on 15/8/3.
  6. // Copyright (c) 2015年 Netease. All rights reserved.
  7. //
  8. #import "NTESSessionWhiteBoardContentView.h"
  9. #import "NTESSessionUtil.h"
  10. #import "UIView+NTES.h"
  11. #import "M80AttributedLabel.h"
  12. #import "NIMKitUtil.h"
  13. #import "NTESWhiteboardAttachment.h"
  14. @interface NTESSessionWhiteBoardContentView()
  15. @property (nonatomic,strong) UIImageView *imageView;
  16. @end
  17. @implementation NTESSessionWhiteBoardContentView
  18. -(instancetype)initSessionMessageContentView
  19. {
  20. if (self = [super initSessionMessageContentView]) {
  21. _textLabel = [[M80AttributedLabel alloc] initWithFrame:CGRectZero];
  22. _textLabel.autoDetectLinks = NO;
  23. _textLabel.numberOfLines = 0;
  24. _textLabel.lineBreakMode = NSLineBreakByWordWrapping;
  25. _textLabel.font = [UIFont systemFontOfSize:14.f];
  26. _textLabel.backgroundColor = [UIColor clearColor];
  27. [self addSubview:_textLabel];
  28. _imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_whiteboard_session_msg"]];
  29. [self addSubview:_imageView];
  30. }
  31. return self;
  32. }
  33. - (void)refresh:(NIMMessageModel *)data{
  34. [super refresh:data];
  35. NIMCustomObject *object = (NIMCustomObject *)data.message.messageObject;
  36. NTESWhiteboardAttachment *attach = (NTESWhiteboardAttachment *)object.attachment;
  37. NSString *text = attach.formatedMessage;
  38. [_textLabel setText:text];
  39. if (!data.message.isOutgoingMsg) {
  40. _textLabel.textColor = [UIColor blackColor];
  41. }else{
  42. _textLabel.textColor = [UIColor whiteColor];
  43. }
  44. }
  45. - (void)layoutSubviews{
  46. [super layoutSubviews];
  47. UIEdgeInsets contentInsets = self.model.contentViewInsets;
  48. CGFloat tableViewWidth = self.superview.width;
  49. CGSize contentSize = [self.model contentSize:tableViewWidth];
  50. self.imageView.left = contentInsets.left;
  51. self.imageView.centerY = self.height * .5f;
  52. CGFloat customWhiteBorardMessageImageRightToText = 5.f;
  53. CGRect labelFrame = CGRectMake(self.imageView.right + customWhiteBorardMessageImageRightToText, contentInsets.top, contentSize.width, contentSize.height);
  54. self.textLabel.frame = labelFrame;
  55. }
  56. @end