ExamStatisticsCell.m 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. //
  2. // ExamStatisticsCell.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/29.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "ExamStatisticsCell.h"
  9. #import "ExamStatisticsModel.h"
  10. @interface ExamStatisticsCell ()
  11. @property (nonatomic, readwrite, strong) UILabel *timeLabel;
  12. @property (nonatomic, readwrite, strong) UIImageView *centerLineView;
  13. @property (nonatomic, readwrite, strong) UILabel *carTyepLabel;
  14. @property (nonatomic, readwrite, strong) UILabel *examNumLabel;
  15. @property (nonatomic, readwrite, strong) UILabel *passNumLabel;
  16. @property (nonatomic, readwrite, strong) YYLabel *passPercentLabel;
  17. @end
  18. @implementation ExamStatisticsCell
  19. #pragma mark - Life Cycle
  20. - (instancetype)initWithFrame:(CGRect)frame {
  21. self = [super initWithFrame:frame];
  22. if (self) {
  23. self.contentView.backgroundColor = UIColor.whiteColor;
  24. [self.contentView addSubview:self.timeLabel];
  25. [self.contentView addSubview:self.centerLineView];
  26. [self.contentView addSubview:self.carTyepLabel];
  27. [self.contentView addSubview:self.examNumLabel];
  28. [self.contentView addSubview:self.passNumLabel];
  29. [self.contentView addSubview:self.passPercentLabel];
  30. }
  31. return self;
  32. }
  33. - (void)layoutSubviews {
  34. [super layoutSubviews];
  35. [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.top.left.mas_offset(16);
  37. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 2), (self.bounds.size.height - 5 * 16) / 3.f));
  38. }];
  39. [_centerLineView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.top.mas_equalTo(_timeLabel.mas_bottom).mas_offset(16);
  41. make.left.mas_equalTo(_timeLabel);
  42. make.right.mas_offset(0);
  43. make.height.mas_equalTo(1);
  44. }];
  45. [_carTyepLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.mas_equalTo(_centerLineView.mas_bottom).mas_offset(16);
  47. make.left.mas_equalTo(_timeLabel);
  48. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 3) * (1.f / 2.f), (self.bounds.size.height - 5 * 16) / 3.f));
  49. }];
  50. [_examNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.top.mas_equalTo(_carTyepLabel);
  52. make.right.mas_offset(-16);
  53. make.size.mas_equalTo(_carTyepLabel);
  54. }];
  55. [_passNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.top.mas_equalTo(_carTyepLabel.mas_bottom).mas_offset(16);
  57. make.left.mas_equalTo(_timeLabel);
  58. make.size.mas_equalTo(_carTyepLabel);
  59. }];
  60. [_passPercentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.top.mas_equalTo(_examNumLabel.mas_bottom).mas_offset(16);
  62. make.right.mas_equalTo(-16);
  63. make.size.mas_equalTo(_carTyepLabel);
  64. }];
  65. }
  66. #pragma mark - HDUpdateUIProtocol
  67. - (void)updateCellUI:(__kindof HDCellModel *)model {
  68. ExamStatisticsModel *examStatisticsModel = model.orgData;
  69. self.timeLabel.text = [NSString stringWithFormat:@"考试时间:%@", examStatisticsModel.time];
  70. self.carTyepLabel.text = [NSString stringWithFormat:@"培训车型:%@", examStatisticsModel.carType];
  71. self.examNumLabel.text = [NSString stringWithFormat:@"排考数:%@", examStatisticsModel.examNum];
  72. self.passNumLabel.text = [NSString stringWithFormat:@"通过数量:%@", examStatisticsModel.passNum];
  73. _passPercentLabel.text = [NSString stringWithFormat:@"通过率:%@",examStatisticsModel.passPercent];
  74. NSMutableAttributedString *remarkLabelAttStr = [[NSMutableAttributedString alloc] initWithString:_passPercentLabel.text];
  75. remarkLabelAttStr.yy_color = RQGreenColor;
  76. [remarkLabelAttStr yy_setColor:RQTitleTextColor range:[_passPercentLabel.text rangeOfString:@"通过率:"]];
  77. remarkLabelAttStr.yy_font = [UIFont systemFontOfSize:16];
  78. remarkLabelAttStr.yy_alignment = NSTextAlignmentRight;
  79. _passPercentLabel.attributedText = remarkLabelAttStr;
  80. }
  81. #pragma mark - Lazy Load
  82. - (UILabel *)timeLabel {
  83. if (!_timeLabel) {
  84. _timeLabel = [[UILabel alloc] init];
  85. _timeLabel.text = @"考试时间:2019-09-09";
  86. _timeLabel.textAlignment = NSTextAlignmentLeft;
  87. _timeLabel.textColor = RQContentTextColor;
  88. _timeLabel.numberOfLines = 0;
  89. _timeLabel.font = [UIFont systemFontOfSize:16];
  90. }
  91. return _timeLabel;
  92. }
  93. - (UIImageView *)centerLineView {
  94. if (!_centerLineView) {
  95. _centerLineView = [[UIImageView alloc] init];
  96. _centerLineView.backgroundColor = RQBackGroundColor;
  97. }
  98. return _centerLineView;
  99. }
  100. - (UILabel *)carTyepLabel {
  101. if (!_carTyepLabel) {
  102. _carTyepLabel = [[UILabel alloc] init];
  103. _carTyepLabel.text = @"培训车型:C1";
  104. _carTyepLabel.textAlignment = NSTextAlignmentLeft;
  105. _carTyepLabel.textColor = RQTitleTextColor;
  106. _carTyepLabel.numberOfLines = 0;
  107. _carTyepLabel.font = [UIFont systemFontOfSize:16];
  108. }
  109. return _carTyepLabel;
  110. }
  111. - (UILabel *)examNumLabel {
  112. if (!_examNumLabel) {
  113. _examNumLabel = [[UILabel alloc] init];
  114. _examNumLabel.text = @"排考数:0";
  115. _examNumLabel.textAlignment = NSTextAlignmentRight;
  116. _examNumLabel.textColor = RQTitleTextColor;
  117. _examNumLabel.numberOfLines = 0;
  118. _examNumLabel.font = [UIFont systemFontOfSize:16];
  119. }
  120. return _examNumLabel;
  121. }
  122. - (UILabel *)passNumLabel {
  123. if (!_passNumLabel) {
  124. _passNumLabel = [[UILabel alloc] init];
  125. _passNumLabel.text = @"通过数量:0";
  126. _passNumLabel.textAlignment = NSTextAlignmentLeft;
  127. _passNumLabel.textColor = RQTitleTextColor;
  128. _passNumLabel.numberOfLines = 0;
  129. _passNumLabel.font = [UIFont systemFontOfSize:16];
  130. }
  131. return _passNumLabel;
  132. }
  133. - (YYLabel *)passPercentLabel {
  134. if (!_passPercentLabel) {
  135. _passPercentLabel = [[YYLabel alloc] init];
  136. _passPercentLabel.text = @"通过率:0%";
  137. _passPercentLabel.textAlignment = NSTextAlignmentRight;
  138. _passPercentLabel.textColor = RQTitleTextColor;
  139. _passPercentLabel.numberOfLines = 0;
  140. _passPercentLabel.font = [UIFont systemFontOfSize:16];
  141. }
  142. return _passPercentLabel;
  143. }
  144. @end