// // HomeLiveCouseCell.m // KulexiuForStudent // // Created by 王智 on 2022/4/22. // #import "HomeLiveCouseCell.h" @interface HomeLiveCouseCell () @property (weak, nonatomic) IBOutlet UIImageView *coverImage; @property (weak, nonatomic) IBOutlet UILabel *courseName; @property (weak, nonatomic) IBOutlet UILabel *teacherName; @property (weak, nonatomic) IBOutlet UIImageView *teacherAvatar; @property (weak, nonatomic) IBOutlet UILabel *courseBegin; @property (weak, nonatomic) IBOutlet UILabel *priceLabel; @property (weak, nonatomic) IBOutlet UILabel *descLabel; @property (weak, nonatomic) IBOutlet UILabel *subjectLabel; @end @implementation HomeLiveCouseCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code self.selectionStyle = UITableViewCellSelectionStyleNone; } - (void)configWithSource:(HomeLiveGroupModel *)source { [self.coverImage sd_setImageWithURL:[NSURL URLWithString:[source.backgroundPic getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"video_placeholder"]]; self.courseName.text = [NSString returnNoNullStringWithString:source.courseGroupName]; if ([NSString isEmptyString:source.teacherName]) { self.teacherName.text = [NSString stringWithFormat:@"游客%@",source.teacherId]; } else { self.teacherName.text = [NSString stringWithFormat:@"%@",source.teacherName]; } [self.teacherAvatar sd_setImageWithURL:[NSURL URLWithString:[source.avatar getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:TEACHER_AVATAR]]; if (source.courseGroupPrice > 0) { NSString *mountMsg = [NSString formatDoubleNum:source.courseGroupPrice]; NSString *descMsg = [NSString stringWithFormat:@"¥%@",mountMsg]; NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:descMsg attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0f],NSForegroundColorAttributeName:HexRGB(0xfa6400)}]; [attr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0f weight:UIFontWeightSemibold]} range:[descMsg rangeOfString:mountMsg]]; self.priceLabel.attributedText = attr; } else { self.priceLabel.text = @"免费"; } NSString *courseMsg = [NSString stringWithFormat:@"%zd课时",source.courseNum]; self.descLabel.text = courseMsg; // 时间 if ([NSString isEmptyString:source.courseStartTime]) { self.courseBegin.text = @""; } else { NSDateFormatter *dateFormatter = [NSObject getDateformatter]; [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; NSDate *beginDate = [dateFormatter dateFromString:source.courseStartTime]; [dateFormatter setDateFormat:@"MM月dd日 HH:mm"]; self.courseBegin.text = [NSString returnNoNullStringWithString:[dateFormatter stringFromDate:beginDate]]; } self.subjectLabel.text = [NSString returnNoNullStringWithString:source.subjectName]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end