// // PreExamInfoCell.m // LN_School // // Created by 张嵘 on 2019/7/26. // Copyright © 2019 Danson. All rights reserved. // #import "PreExamInfoCell.h" #import "PreExamInfoModel.h" @interface PreExamInfoCell () @property (nonatomic, readwrite, strong) UILabel *driverObjectLabel; @property (nonatomic, readwrite, strong) UILabel *timeLabel; @property (nonatomic, readwrite, strong) YYLabel *scoreLabel; @end @implementation PreExamInfoCell #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.scoreLabel]; [self.contentView addSubview:self.driverObjectLabel]; } __weak typeof(self) weakS = self; [self addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) { [weakS clickSelf]; }]; return self; } - (void)layoutSubviews { [super layoutSubviews]; [_driverObjectLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.mas_offset(16); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (16 * 3)) / 2.0, (self.bounds.size.height - (16 * 3)) / 2.0)); }]; [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_driverObjectLabel); make.right.mas_offset(-16); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (16 * 3)) / 2.0, (self.bounds.size.height - (16 * 3)) / 2.0)); }]; [_scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_driverObjectLabel.mas_bottom).mas_offset(16); make.left.mas_equalTo(_driverObjectLabel); make.bottom.mas_offset(-16); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (16 * 2)), (self.bounds.size.height - (16 * 3)) / 2.0)); }]; } #pragma mark - HDUpdateUIProtocol - (void)updateCellUI:(__kindof HDCellModel *)model { PreExamInfoModel *preExamInfoModel = model.orgData; _timeLabel.text = [NSString stringWithFormat:@"时间:%@",preExamInfoModel.time]; _driverObjectLabel.text = [NSString stringWithFormat:@"类型:%@",preExamInfoModel.object]; _scoreLabel.text = [NSString stringWithFormat:@"分数:%@",preExamInfoModel.score]; NSMutableAttributedString *remarkLabelAttStr = [[NSMutableAttributedString alloc] initWithString:_scoreLabel.text]; remarkLabelAttStr.yy_color = (preExamInfoModel.score.integerValue >= 90)? RQGreenColor : RQRedColor; [remarkLabelAttStr yy_setColor:RQTitleTextColor range:[_scoreLabel.text rangeOfString:@"分数:"]]; remarkLabelAttStr.yy_font = [UIFont systemFontOfSize:15]; remarkLabelAttStr.yy_alignment = NSTextAlignmentLeft; _scoreLabel.attributedText = remarkLabelAttStr; } #pragma mark - Private Functions - (void)clickSelf { self.callback(self.hdModel); } #pragma mark - Lazy Load - (UILabel *)driverObjectLabel { if (!_driverObjectLabel) { _driverObjectLabel = [[UILabel alloc] init]; _driverObjectLabel.text = @"科目:"; _driverObjectLabel.textAlignment = NSTextAlignmentLeft; _driverObjectLabel.textColor = RQTitleTextColor; _driverObjectLabel.numberOfLines = 0; _driverObjectLabel.font = [UIFont systemFontOfSize:15]; } return _driverObjectLabel; } - (UILabel *)timeLabel { if (!_timeLabel) { _timeLabel = [[UILabel alloc] init]; _timeLabel.text = @"时间:"; _timeLabel.textAlignment = NSTextAlignmentRight; _timeLabel.textColor = RQTitleTextColor; _timeLabel.numberOfLines = 0; _timeLabel.font = [UIFont systemFontOfSize:15]; } return _timeLabel; } - (YYLabel *)scoreLabel { if (!_scoreLabel) { _scoreLabel = [[YYLabel alloc] init]; _scoreLabel.text = @"分数:"; _scoreLabel.textAlignment = NSTextAlignmentLeft; _scoreLabel.textColor = RQTitleTextColor; _scoreLabel.numberOfLines = 0; _scoreLabel.font = [UIFont systemFontOfSize:15]; } return _scoreLabel; } @end