PreExamInfoCell.m 3.8 KB

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