Files
peko-ios/YuMi/Modules/YMRoom/View/MessageContainerView/Model/XPMessageInfoModel.m
2024-04-17 16:02:42 +08:00

40 lines
1.0 KiB
Objective-C

//
// YMMessageInfoModel.m
// YUMI
//
// Created by YUMI on 2022/10/21.
//
#import "XPMessageInfoModel.h"
#import "XPRoomMessageConstant.h"
@implementation XPMessageInfoModel
- (instancetype)init {
if ([super init]) {
self.contentLeftMargin = 12;
self.contentRightMargin = 0;
self.contentTopMargin = 10;
self.contentBottomMargin = 10;
self.cellBottomMargin = 6;
self.isUpdateContentFrame = NO;
self.isHiddenBubble = NO;
}
return self;
}
- (void)setContent:(NSAttributedString *)content {
_content = content;
CGFloat width = isMSRTL() ? 10 : 0;
CGSize maxSize = CGSizeMake(kRoomMessageMaxWidth - self.contentLeftMargin - self.contentRightMargin - 12, MAXFLOAT);
YYTextContainer *container = [YYTextContainer containerWithSize:maxSize];
container.maximumNumberOfRows = 0;
YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:self.content];
CGFloat rowHeight = layout.textBoundingSize.height + self.contentTopMargin + self.contentBottomMargin + self.cellBottomMargin;
self.rowHeight = rowHeight + width;
}
@end