// // NIMSessionNotificationContentView.m // NIMKit // // Created by chris on 15/3/9. // Copyright (c) 2015年 Netease. All rights reserved. // #import "NIMSessionNotificationContentView.h" #import "NIMMessageModel.h" #import "UIView+NIM.h" #import "NIMKitUtil.h" #import "UIImage+NIMKit.h" #import "NIMKit.h" #import "HTMLAnalysisHelper.h" #import "YYText.h" @interface NIMSessionNotificationContentView () @property (nonatomic, strong)HTMLAnalysisHelper *helper; @property (strong, nonatomic) YYLabel *label; @end @implementation NIMSessionNotificationContentView - (instancetype)initSessionMessageContentView { if (self = [super initSessionMessageContentView]) { _label = [[YYLabel alloc] initWithFrame:CGRectZero]; _label.numberOfLines = 0; _label.textVerticalAlignment = YYTextVerticalAlignmentTop; [self addSubview:_label]; } return self; } - (HTMLAnalysisHelper *)helper { if (!_helper) { _helper = [[HTMLAnalysisHelper alloc]init]; _helper.linkClickedBlock = ^(NSString * _Nonnull linkStr) { // [[UIApplication sharedApplication] openURL:[NSURL URLWithString:linkStr]]; ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init]; baseWeb.contentUrl = linkStr; [[LCTools getCurrentVC].navigationController pushViewController:baseWeb animated:YES]; }; } return _helper; } - (void)refresh:(NIMMessageModel *)model { [super refresh:model]; //解析HTML字符串 [self.helper analysisWithHTMLStr:model.message.text]; self.label.attributedText = self.helper.closeStr; // NIMKitSetting *setting = [[NIMKit sharedKit].config setting:model.message]; self.label.font = [UIFont systemFontOfSize:12]; // self.label.textColor = [UIColor grayColor]; } - (void)layoutSubviews { [super layoutSubviews]; CGFloat padding = [NIMKit sharedKit].config.maxNotificationTipPadding; self.label.nim_size = [self.label sizeThatFits:CGSizeMake(self.nim_width - 2 * padding, CGFLOAT_MAX)]; self.label.nim_centerX = self.nim_width * .5f; self.label.nim_centerY = self.nim_height * .5f; self.bubbleImageView.frame = CGRectInset(self.label.frame, -8, -4); } @end