Files
featherVoice/QXLive/Mine(音域)/View/亲密关系/QXHeartBeatSpaceRecordCell.m
2025-11-28 22:43:06 +08:00

60 lines
2.2 KiB
Objective-C

//
// QXHeartBeatSpaceRecordCell.m
// QXLive
//
// Created by 启星 on 2025/11/22.
//
#import "QXHeartBeatSpaceRecordCell.h"
@implementation QXHeartBeatSpaceRecordCell
+(instancetype)cellWithTableView:(UITableView *)tableView{
static NSString *cellId = @"QXHeartBeatSpaceRecordCell";
QXHeartBeatSpaceRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell) {
cell = [[NSBundle mainBundle] loadNibNamed:cellId owner:nil options:nil].lastObject;
cell.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
}
return cell;
}
-(void)setUserId:(NSString *)userId{
_userId = userId;
}
-(void)setModel:(QXUserHeartBeatSpaceLogModel *)model{
_model = model;
[self.headerView setHeadIcon:model.from_user_info.avatar dress:model.from_user_info.dress];
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;
self.nameLabel.text = model.from_user_info.nickname;
UIColor *nameColor = RGB16(0xFF53CC);
UIColor *contentNameColor = RGB16(0x4A89FF);
NSString *content = [NSString stringWithFormat:@"%@",model.remark];
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:content];
if ([model.from_user_id isEqualToString:self.userId] ) {
self.nameLabel.textColor = nameColor;
[attr yy_setColor:contentNameColor range:[content rangeOfString:model.to_user_info.nickname]];
}else{
self.nameLabel.textColor = contentNameColor;
[attr yy_setColor:nameColor range:[content rangeOfString:model.to_user_info.nickname]];
}
self.contentLabel.attributedText = attr;
}
- (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