NIMSessionNotificationContentView.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // NIMSessionNotificationContentView.m
  3. // NIMKit
  4. //
  5. // Created by chris on 15/3/9.
  6. // Copyright (c) 2015年 Netease. All rights reserved.
  7. //
  8. #import "NIMSessionNotificationContentView.h"
  9. #import "NIMMessageModel.h"
  10. #import "UIView+NIM.h"
  11. #import "NIMKitUtil.h"
  12. #import "UIImage+NIMKit.h"
  13. #import "NIMKit.h"
  14. #import "HTMLAnalysisHelper.h"
  15. #import "YYText.h"
  16. @interface NIMSessionNotificationContentView ()
  17. @property (nonatomic, strong)HTMLAnalysisHelper *helper;
  18. @property (strong, nonatomic) YYLabel *label;
  19. @end
  20. @implementation NIMSessionNotificationContentView
  21. - (instancetype)initSessionMessageContentView
  22. {
  23. if (self = [super initSessionMessageContentView]) {
  24. _label = [[YYLabel alloc] initWithFrame:CGRectZero];
  25. _label.numberOfLines = 0;
  26. _label.textVerticalAlignment = YYTextVerticalAlignmentTop;
  27. [self addSubview:_label];
  28. }
  29. return self;
  30. }
  31. - (HTMLAnalysisHelper *)helper
  32. {
  33. if (!_helper) {
  34. _helper = [[HTMLAnalysisHelper alloc]init];
  35. _helper.linkClickedBlock = ^(NSString * _Nonnull linkStr) {
  36. // [[UIApplication sharedApplication] openURL:[NSURL URLWithString:linkStr]];
  37. ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init];
  38. baseWeb.contentUrl = linkStr;
  39. [[LCTools getCurrentVC].navigationController pushViewController:baseWeb animated:YES];
  40. };
  41. }
  42. return _helper;
  43. }
  44. - (void)refresh:(NIMMessageModel *)model
  45. {
  46. [super refresh:model];
  47. //解析HTML字符串
  48. [self.helper analysisWithHTMLStr:model.message.text];
  49. self.label.attributedText = self.helper.closeStr;
  50. // NIMKitSetting *setting = [[NIMKit sharedKit].config setting:model.message];
  51. self.label.font = [UIFont systemFontOfSize:12];
  52. // self.label.textColor = [UIColor grayColor];
  53. }
  54. - (void)layoutSubviews
  55. {
  56. [super layoutSubviews];
  57. CGFloat padding = [NIMKit sharedKit].config.maxNotificationTipPadding;
  58. self.label.nim_size = [self.label sizeThatFits:CGSizeMake(self.nim_width - 2 * padding, CGFLOAT_MAX)];
  59. self.label.nim_centerX = self.nim_width * .5f;
  60. self.label.nim_centerY = self.nim_height * .5f;
  61. self.bubbleImageView.frame = CGRectInset(self.label.frame, -8, -4);
  62. }
  63. @end