ExamInfoCell.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // ExamInfoCell.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/29.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "ExamInfoCell.h"
  9. #import "ExamInfoModel.h"
  10. @interface ExamInfoCell ()
  11. @property (nonatomic, readwrite, strong) UILabel *driverObjectLabel;
  12. @property (nonatomic, readwrite, strong) UILabel *timeLabel;
  13. @property (nonatomic, readwrite, strong) UILabel *addressLabel;
  14. @property (nonatomic, readwrite, strong) YYLabel *scoreLabel;
  15. @end
  16. @implementation ExamInfoCell
  17. #pragma mark - Life Cycle
  18. - (instancetype)initWithFrame:(CGRect)frame {
  19. self = [super initWithFrame:frame];
  20. if (self) {
  21. self.contentView.backgroundColor = UIColor.whiteColor;
  22. [self.contentView addSubview:self.timeLabel];
  23. [self.contentView addSubview:self.scoreLabel];
  24. [self.contentView addSubview:self.addressLabel];
  25. [self.contentView addSubview:self.driverObjectLabel];
  26. }
  27. __weak typeof(self) weakS = self;
  28. [self addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
  29. [weakS clickSelf];
  30. }];
  31. return self;
  32. }
  33. - (void)layoutSubviews {
  34. [super layoutSubviews];
  35. [_driverObjectLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.top.left.mas_offset(16);
  37. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (16 * 3)) / 2.0, (self.bounds.size.height - (16 * 3)) / 2.0));
  38. }];
  39. [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.top.mas_equalTo(_driverObjectLabel);
  41. make.right.mas_offset(-16);
  42. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (16 * 3)) / 2.0, (self.bounds.size.height - (16 * 3)) / 2.0));
  43. }];
  44. [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.mas_equalTo(_driverObjectLabel.mas_bottom).mas_offset(16);
  46. make.left.mas_equalTo(_driverObjectLabel);
  47. make.bottom.mas_offset(-16);
  48. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (16 * 3)) / 2.0, (self.bounds.size.height - (16 * 3)) / 2.0));
  49. }];
  50. [_scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.top.mas_equalTo(_timeLabel.mas_bottom).mas_offset(16);
  52. make.right.mas_offset(-16);
  53. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (16 * 3)) / 2.0, (self.bounds.size.height - (16 * 3)) / 2.0));
  54. }];
  55. }
  56. #pragma mark - HDUpdateUIProtocol
  57. - (void)updateCellUI:(__kindof HDCellModel *)model {
  58. ExamInfoModel *examInfoModel = model.orgData;
  59. _timeLabel.text = [NSString stringWithFormat:@"考试时间:%@",examInfoModel.time];
  60. _driverObjectLabel.text = [NSString stringWithFormat:@"类型:%@",examInfoModel.object];
  61. _addressLabel.text = [NSString stringWithFormat:@"考试地点:%@",examInfoModel.address];
  62. _scoreLabel.text = [NSString stringWithFormat:@"成绩:%@",examInfoModel.score];
  63. NSMutableAttributedString *remarkLabelAttStr = [[NSMutableAttributedString alloc] initWithString:_scoreLabel.text];
  64. remarkLabelAttStr.yy_color = (examInfoModel.score.integerValue >= 90)? RQGreenColor : RQRedColor;
  65. [remarkLabelAttStr yy_setColor:RQTitleTextColor range:[_scoreLabel.text rangeOfString:@"成绩:"]];
  66. remarkLabelAttStr.yy_font = [UIFont systemFontOfSize:15];
  67. remarkLabelAttStr.yy_alignment = NSTextAlignmentRight;
  68. _scoreLabel.attributedText = remarkLabelAttStr;
  69. }
  70. #pragma mark - Private Functions
  71. - (void)clickSelf {
  72. self.callback(self.hdModel);
  73. }
  74. #pragma mark - Lazy Load
  75. - (UILabel *)driverObjectLabel {
  76. if (!_driverObjectLabel) {
  77. _driverObjectLabel = [[UILabel alloc] init];
  78. _driverObjectLabel.text = @"科目:";
  79. _driverObjectLabel.textAlignment = NSTextAlignmentLeft;
  80. _driverObjectLabel.textColor = RQTitleTextColor;
  81. _driverObjectLabel.numberOfLines = 0;
  82. _driverObjectLabel.font = [UIFont systemFontOfSize:15];
  83. }
  84. return _driverObjectLabel;
  85. }
  86. - (UILabel *)timeLabel {
  87. if (!_timeLabel) {
  88. _timeLabel = [[UILabel alloc] init];
  89. _timeLabel.text = @"时间:";
  90. _timeLabel.textAlignment = NSTextAlignmentRight;
  91. _timeLabel.textColor = RQTitleTextColor;
  92. _timeLabel.numberOfLines = 0;
  93. _timeLabel.font = [UIFont systemFontOfSize:15];
  94. }
  95. return _timeLabel;
  96. }
  97. - (UILabel *)addressLabel {
  98. if (!_addressLabel) {
  99. _addressLabel = [[UILabel alloc] init];
  100. _addressLabel.text = @"地址:";
  101. _addressLabel.textAlignment = NSTextAlignmentLeft;
  102. _addressLabel.textColor = RQTitleTextColor;
  103. _addressLabel.numberOfLines = 0;
  104. _addressLabel.font = [UIFont systemFontOfSize:15];
  105. }
  106. return _addressLabel;
  107. }
  108. - (YYLabel *)scoreLabel {
  109. if (!_scoreLabel) {
  110. _scoreLabel = [[YYLabel alloc] init];
  111. _scoreLabel.text = @"分数:";
  112. _scoreLabel.textAlignment = NSTextAlignmentRight;
  113. _scoreLabel.textColor = RQTitleTextColor;
  114. _scoreLabel.numberOfLines = 0;
  115. _scoreLabel.font = [UIFont systemFontOfSize:15];
  116. }
  117. return _scoreLabel;
  118. }
  119. @end