ExamArrangeCell.m 6.3 KB

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