// // packageRoolCell.m // shiku_im // // Created by 123 on 2020/4/30. // Copyright © 2020 Reese. All rights reserved. // #import "packageRoolCell.h" #import "UIView+LK.h" @interface packageRoolCell() @property (nonatomic,strong) UILabel *nameL; @property (nonatomic,weak) UILabel *priceL; @property (nonatomic, weak)UILabel *contentL; @end @implementation packageRoolCell -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if(self= [super initWithStyle:style reuseIdentifier:reuseIdentifier]){ self.nameL = [[UILabel alloc] init]; self.nameL.font=[UIFont systemFontOfSize:16 weight:UIFontWeightRegular]; self.nameL.textColor=[UIColor whiteColor]; [self addSubview:self.nameL]; [self.nameL mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(self.centerY).mas_offset(0); make.left.mas_equalTo(10); }]; UILabel *priceL = [[UILabel alloc]init]; priceL.font=[UIFont systemFontOfSize:16 weight:UIFontWeightRegular]; priceL.textColor=[UIColor yellowColor]; priceL.textAlignment=NSTextAlignmentLeft; priceL.numberOfLines=3; [self addSubview:priceL]; self.priceL=priceL; [priceL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.nameL.mas_right).mas_offset(8); make.centerY.mas_equalTo(self.nameL.centerY).mas_offset(0); }]; UILabel *contentL = [[UILabel alloc]init]; contentL.font=[UIFont systemFontOfSize:16 weight:UIFontWeightRegular]; contentL.textColor=[UIColor whiteColor]; contentL.textAlignment=NSTextAlignmentLeft; contentL.numberOfLines=3; [self addSubview:contentL]; self.contentL=contentL; [contentL mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-15); make.centerY.mas_equalTo(self.nameL.centerY).mas_offset(0); }]; } return self; } +(instancetype)cellWithTableView:(UITableView *)tableView{ static NSString *ID = @"packageRoolCell"; packageRoolCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (cell == nil) { cell = [[packageRoolCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID]; } cell.backgroundColor = [UIColor clearColor]; cell.selectionStyle=UITableViewCellSelectionStyleNone; return cell; } -(void)setModel:(packageRoolModel *)model{ _model=model; self.nameL.text=[NSString stringWithFormat:@"恭喜%@",model.userName]; self.priceL.text=[NSString stringWithFormat:@"获得%@",model.money]; NSString *timeStr=[self timeFormate:model.gmtCreate]; self.contentL.text=[NSString stringWithFormat:@"%@",timeStr]; } - (NSString *)timeFormate:(NSString *)timeS{ NSTimeInterval time=[timeS doubleValue]+28800;//因为时差问题要加8小时 == 28800 sec NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time/1000]; NSLog(@"date:%@",[detaildate description]); //实例化一个NSDateFormatter对象 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; //设定时间格式,这里可以设置成自己需要的格式 [dateFormatter setDateFormat:@"yyyy-MM-dd"]; NSString *currentDateStr = [dateFormatter stringFromDate: detaildate]; return currentDateStr; } @end