2025-08-08 10:49:36 +08:00
|
|
|
|
//
|
|
|
|
|
|
// QXSystemMessageCell.m
|
|
|
|
|
|
// QXLive
|
|
|
|
|
|
//
|
|
|
|
|
|
// Created by 启星 on 2025/5/29.
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import "QXSystemMessageCell.h"
|
|
|
|
|
|
|
|
|
|
|
|
@implementation QXSystemMessageCell
|
|
|
|
|
|
+(instancetype)cellWithTableView:(UITableView *)tableView{
|
|
|
|
|
|
static NSString *cellId = @"QXSystemMessageCell";
|
|
|
|
|
|
QXSystemMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
|
|
|
|
|
|
if (!cell) {
|
|
|
|
|
|
cell = [[NSBundle mainBundle] loadNibNamed:cellId owner:nil options:nil].lastObject;
|
|
|
|
|
|
cell.backgroundColor = [UIColor clearColor];
|
|
|
|
|
|
}
|
|
|
|
|
|
return cell;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(void)setModel:(QXMessageListModel *)model{
|
|
|
|
|
|
_model = model;
|
2026-01-04 14:01:30 +08:00
|
|
|
|
NSData *data = [model.content dataUsingEncoding:NSUnicodeStringEncoding];
|
|
|
|
|
|
// 创建段落样式来设置行间距
|
|
|
|
|
|
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
|
|
|
|
|
[paragraphStyle setLineSpacing:8]; // 设置行间距为8磅,可根据需要调整
|
|
|
|
|
|
|
|
|
|
|
|
// 创建options字典,包含文档类型和默认属性
|
|
|
|
|
|
NSDictionary *options = @{
|
|
|
|
|
|
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
|
|
|
|
|
|
NSDefaultAttributesDocumentAttribute: @{
|
|
|
|
|
|
NSParagraphStyleAttributeName: paragraphStyle
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
// 转换为富文本
|
|
|
|
|
|
NSAttributedString *html = [[NSAttributedString alloc] initWithData:data
|
|
|
|
|
|
options:options
|
|
|
|
|
|
documentAttributes:nil
|
|
|
|
|
|
error:nil];
|
|
|
|
|
|
self.contentLabel.attributedText = html;
|
2025-08-08 10:49:36 +08:00
|
|
|
|
NSDate *date = [NSDate dateWithTimeIntervalSince1970:model.createtime.longLongValue]; //此处根据项目需求,选择是否除以1000 , 如果时间戳精确到秒则去掉1000
|
|
|
|
|
|
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
|
|
|
|
|
|
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
|
|
|
|
|
|
NSString*time = [formatter stringFromDate:date];
|
|
|
|
|
|
self.timeLabel.text = time;
|
|
|
|
|
|
}
|
|
|
|
|
|
- (void)awakeFromNib {
|
|
|
|
|
|
[super awakeFromNib];
|
|
|
|
|
|
// Initialization code
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
|
|
|
|
|
[super setSelected:selected animated:animated];
|
|
|
|
|
|
|
|
|
|
|
|
// Configure the view for the selected state
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|