表情公屏显示

This commit is contained in:
fengshuo
2022-03-10 18:49:50 +08:00
parent c5ca1c39c2
commit af4521d82a
3 changed files with 59 additions and 7 deletions

View File

@@ -15,6 +15,7 @@
#import "AccountInfoStorage.h"
#import "XPMacro.h"
#import "XPGiftStorage.h"
#import "XPRoomFaceTool.h"
///Model
#import "XPMessageRemoteExtModel.h"
#import "AttachmentModel.h"
@@ -25,6 +26,8 @@
#import "MicroStateModel.h"
#import "RoomInfoModel.h"
#import "DatingInfoModel.h"
#import "RoomFaceInfoModel.h"
#import "RoomFaceSendInfoModel.h"
#import "NetImageView.h"
@@ -79,7 +82,9 @@
return [self createRoomDatingAttribute:attachment];
} else if (first == CustomMessageType_Noble_VIP) {//
return [self createNobleLevelAttribute:attachment];
}
} else if (first == CustomMessageType_Face) {//
return [self createRoomFaceAttribute:attachment];
}
return nil;
}
@@ -176,6 +181,34 @@
return nil;
}
#pragma mark -
- (NSAttributedString*)createRoomFaceAttribute:(AttachmentModel *)attachment {
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
if ([attachment.data[@"data"] isKindOfClass:[NSArray class]]) {
NSArray * array = [RoomFaceSendInfoModel modelsWithArray:attachment.data[@"data"]];
for (int i = 0; i< array.count; i++) {
RoomFaceSendInfoModel * sendFaceInfo = [array objectAtIndex:i];
[attribute appendAttributedString:[self createTextAttribute:sendFaceInfo.nick color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:@":" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:@"\n" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
for (int j = 0; j < sendFaceInfo.resultIndexes.count; j++) {
NSNumber *index = sendFaceInfo.resultIndexes[j];
UIImage *face = [[XPRoomFaceTool shareFaceTool] findFaceImageById:sendFaceInfo.faceId index:[index integerValue]];
if (face) {
UIImageView *imageView = [[UIImageView alloc]init];
imageView.image = face;
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.bounds = CGRectMake(0, 0, 30, 30);
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
[attribute appendAttributedString:[self createSapceAttribute:1]];
[attribute appendAttributedString:attrString];
}
}
}
}
return attribute;
}
#pragma mark -
- (NSAttributedString*)createCollectRoomAttribute:(AttachmentModel *)attachment {
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];