// // HDLEZDeviceMsgCell.m // EZSDK // // Created by 陈启扬 on 2023/3/16. // #import "HDLEZDeviceMsgCell.h" @interface HDLEZDeviceMsgCell(){ UIFont *titleFont,*describeFont; } @property (nonatomic, strong)UILabel *titleL;//标题lable @property (nonatomic, strong)UILabel *timeL;//时间lable @property (nonatomic, strong)UILabel *describeL;//描述lable @property (nonatomic, strong)UIView *lineV;//下划线 @end @implementation HDLEZDeviceMsgCell - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } -(instancetype)initWithFrame:(CGRect)frame{ if(self = [super initWithFrame:frame]){ self.frame=frame; self.selectionStyle=UITableViewCellSelectionStyleNone; titleFont=HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_14); describeFont=HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_12); [self initUI]; } return self; } -(void)initUI{ //标题L _titleL=[[UILabel alloc] init]; _titleL.font=titleFont; _titleL.textColor=HDLEZ_COLOR_TITLE_BLACK; _titleL.adjustsFontSizeToFitWidth=YES; [self.contentView addSubview:_titleL]; [_titleL mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView).offset(12); make.left.equalTo(self.contentView).offset(16); make.height.mas_equalTo(22); make.right.equalTo(self.contentView).offset(-16); }]; //时间L _timeL=[[UILabel alloc] init]; _timeL.font=describeFont; _timeL.textColor=HDLEZ_COLOR_TEXT_LIGHT_GRAY; _timeL.adjustsFontSizeToFitWidth=YES; [self.contentView addSubview:_timeL]; [_timeL mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.contentView).offset(-12); make.left.equalTo(_titleL); make.height.mas_equalTo(17); make.width.mas_equalTo(120); }]; //描述L _describeL=[[UILabel alloc] init]; _describeL.font=describeFont; _describeL.textColor=HDLEZ_COLOR_TEXT_LIGHT_GRAY; _describeL.adjustsFontSizeToFitWidth=YES; _describeL.textAlignment=NSTextAlignmentRight; [self.contentView addSubview:_describeL]; [_describeL mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.contentView).offset(-12); make.height.mas_equalTo(17); make.right.equalTo(_titleL); make.left.equalTo(_timeL.mas_right); }]; //下划线 _lineV=[[UIView alloc] init]; [self.contentView addSubview:_lineV]; [_lineV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(_titleL.mas_left); make.bottom.equalTo(self.contentView); make.right.equalTo(_describeL.mas_right); make.height.mas_equalTo(1); }]; _lineV.backgroundColor=HDLEZ_COLOR_BACKGROUND_LINE; } /*时间戳转时间 */ -(NSString *)turnDate:(NSString*)dateStr{ return [HDLEZConstants timeStrWithFormate:[NSString stringWithFormat:@"yyyy%@MM%@dd%@ HH:mm",HDLEZLocallizedString(@"device_temp_year"),HDLEZLocallizedString(@"device_temp_month"),HDLEZLocallizedString(@"device_temp_date")] data:[NSDate dateWithTimeIntervalSince1970:[dateStr doubleValue]/1000]]; } /*设置消息值 */ -(void)setMsgInfo:(HDLEZDeviceMsgInfoModel *)msgInfo{ _msgInfo=msgInfo; _titleL.text=[HDLEZConstants turnNil:msgInfo.title] ; _timeL.text=[NSString stringWithFormat:@"%@",[self turnDate:msgInfo.createTime]]; _describeL.text=[HDLEZConstants turnNil:msgInfo.content]; } @end