SignUpSituationCell.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // SignUpSituationCell.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/31.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "SignUpSituationCell.h"
  9. #import "SignUpSituationModel.h"
  10. @interface SignUpSituationCell ()
  11. @property (nonatomic, readwrite, strong) UIImageView *headImageView;
  12. @property (nonatomic, readwrite, strong) UILabel *nameLabel;
  13. @property (nonatomic, readwrite, strong) UILabel *sexLabel;
  14. @property (nonatomic, readwrite, strong) UILabel *schoolLabel;
  15. @property (nonatomic, readwrite, strong) UIImageView *arrowImageView;
  16. @property (nonatomic, readwrite, strong) UIImageView *bottomLineView;
  17. @end
  18. @implementation SignUpSituationCell
  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.headImageView];
  25. [self.contentView addSubview:self.nameLabel];
  26. [self.contentView addSubview:self.sexLabel];
  27. [self.contentView addSubview:self.schoolLabel];
  28. [self.contentView addSubview:self.arrowImageView];
  29. [self.contentView addSubview:self.bottomLineView];
  30. }
  31. __weak typeof(self) weakS = self;
  32. [self addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
  33. [weakS clickSelf];
  34. }];
  35. return self;
  36. }
  37. - (void)layoutSubviews {
  38. [super layoutSubviews];
  39. CGFloat width = self.bounds.size.width - 16 - 16 - 16;
  40. [_headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.centerY.mas_equalTo(self.contentView);
  42. make.left.mas_equalTo(self.contentView).mas_offset(16);
  43. make.size.mas_equalTo(CGSizeMake(width * 0.15, width * 0.15));
  44. }];
  45. [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.mas_equalTo(self.contentView).mas_offset(8);
  47. make.left.mas_equalTo(_headImageView.mas_right).mas_offset(16);
  48. make.size.mas_equalTo(CGSizeMake(width * 0.425, self.bounds.size.height * 0.4));
  49. }];
  50. [_sexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.left.mas_equalTo(_nameLabel);
  52. make.bottom.mas_equalTo(self.contentView).mas_offset(-8);
  53. make.size.mas_equalTo(_nameLabel);
  54. }];
  55. [_arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.centerY.mas_equalTo(self.contentView);
  57. make.right.mas_equalTo(self.contentView).mas_offset(-16);
  58. make.size.mas_equalTo(CGSizeMake(width * 0.025, (width * 0.025) * (39.0 / 21.0)));
  59. }];
  60. [_schoolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.centerY.mas_equalTo(self.contentView);
  62. make.right.mas_equalTo(_arrowImageView.mas_left);
  63. make.size.mas_equalTo(CGSizeMake(width * 0.4, self.bounds.size.height * 0.4));
  64. }];
  65. [_bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.mas_offset(16);
  67. make.right.mas_offset(-16);
  68. make.bottom.mas_offset(0);
  69. make.height.mas_equalTo(1);
  70. }];
  71. }
  72. #pragma mark - HDUpdateUIProtocol
  73. - (void)updateCellUI:(__kindof HDCellModel *)model {
  74. SignUpSituationModel *signUpSituationModel = model.orgData;
  75. self.headImageView.image = [UIImage imageNamed:signUpSituationModel.imageName];
  76. self.nameLabel.text = [NSString stringWithFormat:@"姓名:%@",signUpSituationModel.name];
  77. self.sexLabel.text = [NSString stringWithFormat:@"性别:%@",signUpSituationModel.sex];
  78. self.schoolLabel.text = [NSString stringWithFormat:@"驾校:%@",signUpSituationModel.school];
  79. }
  80. #pragma mark - Private Functions
  81. - (void)clickSelf {
  82. self.callback(self.hdModel);
  83. }
  84. #pragma mark - Lazy Load
  85. - (UIImageView *)headImageView {
  86. if (!_headImageView) {
  87. _headImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"HeaderPlacehold"]];
  88. }
  89. return _headImageView;
  90. }
  91. - (UILabel *)nameLabel {
  92. if (!_nameLabel) {
  93. _nameLabel = [[UILabel alloc] init];
  94. _nameLabel.textAlignment = NSTextAlignmentLeft;
  95. _nameLabel.textColor = RQTitleTextColor;
  96. _nameLabel.numberOfLines = 0;
  97. _nameLabel.font = [UIFont systemFontOfSize:15];
  98. }
  99. return _nameLabel;
  100. }
  101. - (UILabel *)sexLabel {
  102. if (!_sexLabel) {
  103. _sexLabel = [[UILabel alloc] init];
  104. _sexLabel.textAlignment = NSTextAlignmentLeft;
  105. _sexLabel.textColor = RQTitleTextColor;
  106. _sexLabel.numberOfLines = 0;
  107. _sexLabel.font = [UIFont systemFontOfSize:15];
  108. }
  109. return _sexLabel;
  110. }
  111. - (UILabel *)schoolLabel {
  112. if (!_schoolLabel) {
  113. _schoolLabel = [[UILabel alloc] init];
  114. _schoolLabel.textAlignment = NSTextAlignmentLeft;
  115. _schoolLabel.textColor = RQTitleTextColor;
  116. _schoolLabel.numberOfLines = 0;
  117. _schoolLabel.font = [UIFont systemFontOfSize:15];
  118. }
  119. return _schoolLabel;
  120. }
  121. - (UIImageView *)arrowImageView {
  122. if (!_arrowImageView) {
  123. _arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Arrow"]];
  124. }
  125. return _arrowImageView;
  126. }
  127. - (UIImageView *)bottomLineView {
  128. if (!_bottomLineView) {
  129. _bottomLineView = [[UIImageView alloc] init];
  130. _bottomLineView.backgroundColor = RQBackGroundColor;
  131. }
  132. return _bottomLineView;
  133. }
  134. @end