// // ExamArrangeCell.m // LN_School // // Created by 张嵘 on 2019/7/29. // Copyright © 2019 Danson. All rights reserved. // #import "ExamArrangeCell.h" #import "ExamArrangeModel.h" @interface ExamArrangeCell () @property (nonatomic, readwrite, strong) UILabel *timeLabel; @property (nonatomic, readwrite, strong) YYLabel *passNumLabel; @property (nonatomic, readwrite, strong) UIImageView *centerLineView; @property (nonatomic, readwrite, strong) UILabel *objectLabel; @property (nonatomic, readwrite, strong) UILabel *carTyepLabel; @property (nonatomic, readwrite, strong) YYLabel *signatureLabel; @property (nonatomic, readwrite, strong) UILabel *examNumLabel; @end @implementation ExamArrangeCell #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.passNumLabel]; [self.contentView addSubview:self.centerLineView]; [self.contentView addSubview:self.objectLabel]; [self.contentView addSubview:self.carTyepLabel]; [self.contentView addSubview:self.signatureLabel]; [self.contentView addSubview:self.examNumLabel]; } 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 * 3) * (2.f / 3.f), (self.bounds.size.height - 5 * 16) / 3.f)); }]; [_passNumLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_offset(16); make.right.mas_equalTo(-16); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 3) * (1.f / 3.f), (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); }]; [_objectLabel 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)); }]; [_carTyepLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_objectLabel); make.right.mas_offset(-16); make.size.mas_equalTo(_objectLabel); }]; [_signatureLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_objectLabel.mas_bottom).mas_offset(16); make.left.mas_equalTo(_objectLabel); make.size.mas_equalTo(_objectLabel); }]; [_examNumLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_carTyepLabel.mas_bottom).mas_offset(16); make.right.mas_equalTo(-16); make.size.mas_equalTo(_objectLabel); }]; } #pragma mark - HDUpdateUIProtocol - (void)updateCellUI:(__kindof HDCellModel *)model { ExamArrangeModel *examArrangeModel = model.orgData; self.timeLabel.text = [NSString stringWithFormat:@"考试时间:%@", examArrangeModel.date]; self.passNumLabel.text = [NSString stringWithFormat:@"通过:%@", examArrangeModel.passNum]; self.objectLabel.text = [NSString stringWithFormat:@"科目:%@", examArrangeModel.object]; self.carTyepLabel.text = [NSString stringWithFormat:@"车型:%@", examArrangeModel.carType]; self.signatureLabel.text = [NSString stringWithFormat:@"签章:%@",examArrangeModel.signature]; self.examNumLabel.text = [NSString stringWithFormat:@"排考:%@", examArrangeModel.examNum]; NSMutableAttributedString *remarkLabelAttStr = [[NSMutableAttributedString alloc] initWithString:self.passNumLabel.text]; remarkLabelAttStr.yy_color = RQGreenColor; [remarkLabelAttStr yy_setColor:RQGreenColor range:[self.passNumLabel.text rangeOfString:self.passNumLabel.text]]; remarkLabelAttStr.yy_font = [UIFont systemFontOfSize:16]; remarkLabelAttStr.yy_alignment = NSTextAlignmentRight; _passNumLabel.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 *)objectLabel { if (!_objectLabel) { _objectLabel = [[UILabel alloc] init]; _objectLabel.text = @"科目:l科目一"; _objectLabel.textAlignment = NSTextAlignmentLeft; _objectLabel.textColor = RQTitleTextColor; _objectLabel.numberOfLines = 0; _objectLabel.font = [UIFont systemFontOfSize:16]; } return _objectLabel; } - (UILabel *)carTyepLabel { if (!_carTyepLabel) { _carTyepLabel = [[UILabel alloc] init]; _carTyepLabel.text = @"车型:C1"; _carTyepLabel.textAlignment = NSTextAlignmentRight; _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; } - (YYLabel *)passNumLabel { if (!_passNumLabel) { _passNumLabel = [[YYLabel alloc] init]; _passNumLabel.text = @"通过数量:0"; _passNumLabel.textAlignment = NSTextAlignmentLeft; _passNumLabel.textColor = RQTitleTextColor; _passNumLabel.numberOfLines = 0; _passNumLabel.font = [UIFont systemFontOfSize:16]; } return _passNumLabel; } - (YYLabel *)signatureLabel { if (!_signatureLabel) { _signatureLabel = [[YYLabel alloc] init]; _signatureLabel.text = @"通过率:0%"; _signatureLabel.textAlignment = NSTextAlignmentLeft; _signatureLabel.textColor = RQTitleTextColor; _signatureLabel.numberOfLines = 0; _signatureLabel.font = [UIFont systemFontOfSize:16]; } return _signatureLabel; } @end