调整铭牌的大小

This commit is contained in:
edwinQQQ
2024-11-28 20:39:27 +08:00
parent a6af37e51b
commit 5fa7595965

View File

@@ -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;
}