123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // ExamInfoCell.m
- // LN_School
- //
- // Created by 张嵘 on 2019/7/29.
- // Copyright © 2019 Danson. All rights reserved.
- //
- #import "ExamInfoCell.h"
- #import "ExamInfoModel.h"
- @interface ExamInfoCell ()
- @property (nonatomic, readwrite, strong) UILabel *driverObjectLabel;
- @property (nonatomic, readwrite, strong) UILabel *timeLabel;
- @property (nonatomic, readwrite, strong) UILabel *addressLabel;
- @property (nonatomic, readwrite, strong) YYLabel *scoreLabel;
- @end
- @implementation ExamInfoCell
- #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.addressLabel];
- [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));
- }];
-
- [_addressLabel 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 * 3)) / 2.0, (self.bounds.size.height - (16 * 3)) / 2.0));
- }];
-
- [_scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(_timeLabel.mas_bottom).mas_offset(16);
- 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));
- }];
- }
- #pragma mark - HDUpdateUIProtocol
- - (void)updateCellUI:(__kindof HDCellModel *)model {
- ExamInfoModel *examInfoModel = model.orgData;
- _timeLabel.text = [NSString stringWithFormat:@"考试时间:%@",examInfoModel.time];
- _driverObjectLabel.text = [NSString stringWithFormat:@"类型:%@",examInfoModel.object];
- _addressLabel.text = [NSString stringWithFormat:@"考试地点:%@",examInfoModel.address];
- _scoreLabel.text = [NSString stringWithFormat:@"成绩:%@",examInfoModel.score];
- NSMutableAttributedString *remarkLabelAttStr = [[NSMutableAttributedString alloc] initWithString:_scoreLabel.text];
- remarkLabelAttStr.yy_color = (examInfoModel.score.integerValue >= 90)? RQGreenColor : RQRedColor;
- [remarkLabelAttStr yy_setColor:RQTitleTextColor range:[_scoreLabel.text rangeOfString:@"成绩:"]];
- remarkLabelAttStr.yy_font = [UIFont systemFontOfSize:15];
- remarkLabelAttStr.yy_alignment = NSTextAlignmentRight;
- _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;
- }
- - (UILabel *)addressLabel {
- if (!_addressLabel) {
- _addressLabel = [[UILabel alloc] init];
- _addressLabel.text = @"地址:";
- _addressLabel.textAlignment = NSTextAlignmentLeft;
- _addressLabel.textColor = RQTitleTextColor;
- _addressLabel.numberOfLines = 0;
- _addressLabel.font = [UIFont systemFontOfSize:15];
- }
- return _addressLabel;
- }
- - (YYLabel *)scoreLabel {
- if (!_scoreLabel) {
- _scoreLabel = [[YYLabel alloc] init];
- _scoreLabel.text = @"分数:";
- _scoreLabel.textAlignment = NSTextAlignmentRight;
- _scoreLabel.textColor = RQTitleTextColor;
- _scoreLabel.numberOfLines = 0;
- _scoreLabel.font = [UIFont systemFontOfSize:15];
- }
- return _scoreLabel;
- }
- @end
|