From 5fa7595965608f06ed0b45c64566a8e3d6c1d70f Mon Sep 17 00:00:00 2001 From: edwinQQQ <> Date: Thu, 28 Nov 2024 20:39:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=93=AD=E7=89=8C=E7=9A=84?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tool/XPRoomMessageParser.m | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m b/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m index af8126c6..58f36c0d 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m @@ -299,13 +299,17 @@ [attribute appendAttributedString:[self createSapceAttribute:2]]; } }else{ - if (model.inRoomNameplatePic.length > 0 && model.inRoomNameplateWord.length > 0) { //铭牌有图片加文字 + if (model.inRoomNameplatePic.length > 0) { //铭牌有图片加文字 [attribute appendAttributedString:[self createNameplateAttibute:model.inRoomNameplateWord image:model.inRoomNameplatePic textFont:[UIFont systemFontOfSize:9]]]; [attribute appendAttributedString:[self createSapceAttribute:2]]; - } else if (model.inRoomNameplatePic.length > 0) {//铭牌只有图片 - [attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic]]; - [attribute appendAttributedString:[self createSapceAttribute:2]]; } +// if (model.inRoomNameplatePic.length > 0 && model.inRoomNameplateWord.length > 0) { //铭牌有图片加文字 +// [attribute appendAttributedString:[self createNameplateAttibute:model.inRoomNameplateWord image:model.inRoomNameplatePic textFont:[UIFont systemFontOfSize:9]]]; +// [attribute appendAttributedString:[self createSapceAttribute:2]]; +// } else if (model.inRoomNameplatePic.length > 0) {//铭牌只有图片 +// [attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic]]; +// [attribute appendAttributedString:[self createSapceAttribute:2]]; +// } } [attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; [attribute appendAttributedString:[self createSapceAttribute:2]]; @@ -1392,12 +1396,12 @@ NetImageConfig *config = [[NetImageConfig alloc]init]; ///先这样吧 config.autoLoad = YES; - NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageName config:config]; + NetImageView *imageView = [[NetImageView alloc] initWithUrl:imageName config:config]; UIImage* image = imageView.image; - if (image) { - CGFloat scale = image.size.width / image.size.height; - imageView.bounds = CGRectMake(0, 0, 18 * scale, 18); - } else { +// if (image) { +// CGFloat scale = image.size.width / image.size.height; +// imageView.bounds = CGRectMake(0, 0, 18 * scale, 18); +// } else { // NSURL *imgUrl = [NSURL URLWithString:imageName]; // UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]]; // if (myImage) { @@ -1410,21 +1414,24 @@ // } else { imageView.bounds = CGRectMake(0, 0, 60, 18); // } - } +// } imageView.contentMode = UIViewContentModeScaleAspectFit; // 铭牌文字 - UILabel *label = [[UILabel alloc] init]; - label.textAlignment = NSTextAlignmentCenter; - label.font = [UIFont boldSystemFontOfSize:12]; - label.adjustsFontSizeToFitWidth = YES; - label.textColor = UIColor.whiteColor; - label.text = tagName; - [imageView addSubview:label]; - [label mas_makeConstraints:^(MASConstraintMaker *make) { - make.leading.mas_equalTo(27); - make.trailing.mas_equalTo(-8); - make.centerY.mas_equalTo(0); - }]; + if (![NSString isEmpty:tagName]) { + UILabel *label = [[UILabel alloc] init]; + label.textAlignment = NSTextAlignmentCenter; + label.font = [UIFont boldSystemFontOfSize:12]; + label.adjustsFontSizeToFitWidth = YES; + label.textColor = UIColor.whiteColor; + label.text = tagName; + [imageView addSubview:label]; + [label mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.mas_equalTo(27); + make.trailing.mas_equalTo(-8); + make.centerY.mas_equalTo(0); + }]; + } + NSMutableAttributedString *string = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView.bounds.size alignToFont:[UIFont boldSystemFontOfSize:12] alignment:YYTextVerticalAlignmentCenter]; return string; }