// // ExamStatisticsCell.m // LN_School // // Created by 张嵘 on 2019/7/29. // Copyright © 2019 Danson. All rights reserved. // #import "ExamStatisticsCell.h" #import "ExamStatisticsModel.h" @interface ExamStatisticsCell () @property (nonatomic, readwrite, strong) UILabel *timeLabel; @property (nonatomic, readwrite, strong) UIImageView *centerLineView; @property (nonatomic, readwrite, strong) UILabel *carTyepLabel; @property (nonatomic, readwrite, strong) UILabel *examNumLabel; @property (nonatomic, readwrite, strong) UILabel *passNumLabel; @property (nonatomic, readwrite, strong) YYLabel *passPercentLabel; @end @implementation ExamStatisticsCell #pragma mark - Life Cycle - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.contentView.backgroundColor = UIColor.whiteColor; [self.contentView addSubview:self.timeLabel]; [self.contentView addSubview:self.centerLineView]; [self.contentView addSubview:self.carTyepLabel]; [self.contentView addSubview:self.examNumLabel]; [self.contentView addSubview:self.passNumLabel]; [self.contentView addSubview:self.passPercentLabel]; } return self; } - (void)layoutSubviews { [super layoutSubviews]; [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.mas_offset(16); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 2), (self.bounds.size.height - 5 * 16) / 3.f)); }]; [_centerLineView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_timeLabel.mas_bottom).mas_offset(16); make.left.mas_equalTo(_timeLabel); make.right.mas_offset(0); make.height.mas_equalTo(1); }]; [_carTyepLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_centerLineView.mas_bottom).mas_offset(16); make.left.mas_equalTo(_timeLabel); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 3) * (1.f / 2.f), (self.bounds.size.height - 5 * 16) / 3.f)); }]; [_examNumLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_carTyepLabel); make.right.mas_offset(-16); make.size.mas_equalTo(_carTyepLabel); }]; [_passNumLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_carTyepLabel.mas_bottom).mas_offset(16); make.left.mas_equalTo(_timeLabel); make.size.mas_equalTo(_carTyepLabel); }]; [_passPercentLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_examNumLabel.mas_bottom).mas_offset(16); make.right.mas_equalTo(-16); make.size.mas_equalTo(_carTyepLabel); }]; } #pragma mark - HDUpdateUIProtocol - (void)updateCellUI:(__kindof HDCellModel *)model { ExamStatisticsModel *examStatisticsModel = model.orgData; self.timeLabel.text = [NSString stringWithFormat:@"考试时间:%@", examStatisticsModel.time]; self.carTyepLabel.text = [NSString stringWithFormat:@"培训车型:%@", examStatisticsModel.carType]; self.examNumLabel.text = [NSString stringWithFormat:@"排考数:%@", examStatisticsModel.examNum]; self.passNumLabel.text = [NSString stringWithFormat:@"通过数量:%@", examStatisticsModel.passNum]; _passPercentLabel.text = [NSString stringWithFormat:@"通过率:%@",examStatisticsModel.passPercent]; NSMutableAttributedString *remarkLabelAttStr = [[NSMutableAttributedString alloc] initWithString:_passPercentLabel.text]; remarkLabelAttStr.yy_color = RQGreenColor; [remarkLabelAttStr yy_setColor:RQTitleTextColor range:[_passPercentLabel.text rangeOfString:@"通过率:"]]; remarkLabelAttStr.yy_font = [UIFont systemFontOfSize:16]; remarkLabelAttStr.yy_alignment = NSTextAlignmentRight; _passPercentLabel.attributedText = remarkLabelAttStr; } #pragma mark - Lazy Load - (UILabel *)timeLabel { if (!_timeLabel) { _timeLabel = [[UILabel alloc] init]; _timeLabel.text = @"考试时间:2019-09-09"; _timeLabel.textAlignment = NSTextAlignmentLeft; _timeLabel.textColor = RQContentTextColor; _timeLabel.numberOfLines = 0; _timeLabel.font = [UIFont systemFontOfSize:16]; } return _timeLabel; } - (UIImageView *)centerLineView { if (!_centerLineView) { _centerLineView = [[UIImageView alloc] init]; _centerLineView.backgroundColor = RQBackGroundColor; } return _centerLineView; } - (UILabel *)carTyepLabel { if (!_carTyepLabel) { _carTyepLabel = [[UILabel alloc] init]; _carTyepLabel.text = @"培训车型:C1"; _carTyepLabel.textAlignment = NSTextAlignmentLeft; _carTyepLabel.textColor = RQTitleTextColor; _carTyepLabel.numberOfLines = 0; _carTyepLabel.font = [UIFont systemFontOfSize:16]; } return _carTyepLabel; } - (UILabel *)examNumLabel { if (!_examNumLabel) { _examNumLabel = [[UILabel alloc] init]; _examNumLabel.text = @"排考数:0"; _examNumLabel.textAlignment = NSTextAlignmentRight; _examNumLabel.textColor = RQTitleTextColor; _examNumLabel.numberOfLines = 0; _examNumLabel.font = [UIFont systemFontOfSize:16]; } return _examNumLabel; } - (UILabel *)passNumLabel { if (!_passNumLabel) { _passNumLabel = [[UILabel alloc] init]; _passNumLabel.text = @"通过数量:0"; _passNumLabel.textAlignment = NSTextAlignmentLeft; _passNumLabel.textColor = RQTitleTextColor; _passNumLabel.numberOfLines = 0; _passNumLabel.font = [UIFont systemFontOfSize:16]; } return _passNumLabel; } - (YYLabel *)passPercentLabel { if (!_passPercentLabel) { _passPercentLabel = [[YYLabel alloc] init]; _passPercentLabel.text = @"通过率:0%"; _passPercentLabel.textAlignment = NSTextAlignmentRight; _passPercentLabel.textColor = RQTitleTextColor; _passPercentLabel.numberOfLines = 0; _passPercentLabel.font = [UIFont systemFontOfSize:16]; } return _passPercentLabel; } @end