123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- //
- // 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
|