StudentDetailInfoHeaderView.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. //
  2. // StudentDetailInfoHeaderView.m
  3. // LN_Schooltr
  4. //
  5. // Created by 张嵘 on 2019/7/25.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "StudentDetailInfoHeaderView.h"
  9. @interface StudentDetailInfoHeaderView ()
  10. @property (nonatomic, readwrite, strong) UIImageView *backgroundView;
  11. @property (nonatomic, readwrite, strong) UIView *contentView;
  12. @property (nonatomic, readwrite, strong) UIImageView *headerImageView;
  13. @property (nonatomic, readwrite, strong) UILabel *nameLabel;
  14. @property (nonatomic, readwrite, strong) UILabel *sexLabel;
  15. @property (nonatomic, readwrite, strong) UILabel *driverSchoolLabel;
  16. @property (nonatomic, readwrite, strong) UILabel *phoneLabel;
  17. @property (nonatomic, readwrite, strong) YYLabel *remarkLabel;
  18. @end
  19. @implementation StudentDetailInfoHeaderView
  20. #pragma mark - Life Cycle
  21. - (instancetype)initWithFrame:(CGRect)frame {
  22. self = [super initWithFrame:frame];
  23. if (self) {
  24. self.backgroundColor = UIColor.whiteColor;
  25. [self addSubview:self.backgroundView];
  26. [self addSubview:self.contentView];
  27. [self.contentView addSubview:self.headerImageView];
  28. [self.contentView addSubview:self.nameLabel];
  29. [self.contentView addSubview:self.sexLabel];
  30. [self.contentView addSubview:self.driverSchoolLabel];
  31. [self.contentView addSubview:self.phoneLabel];
  32. [self.contentView addSubview:self.remarkLabel];
  33. }
  34. return self;
  35. }
  36. - (void)layoutSubviews {
  37. [super layoutSubviews];
  38. [_backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.top.mas_offset(0);
  40. make.centerX.mas_equalTo(self);
  41. make.size.mas_equalTo(CGSizeMake(self.bounds.size.width, self.bounds.size.height * (1.f / 2.f)));
  42. }];
  43. [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.centerX.mas_equalTo(self);
  45. make.bottom.mas_offset(-10);
  46. make.size.mas_equalTo(CGSizeMake(self.bounds.size.width - (2 * 16), self.bounds.size.height * (2.f / 3.f)));
  47. }];
  48. [_headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.top.mas_offset(- self.bounds.size.width / 10.f);
  50. make.centerX.mas_equalTo(self.contentView);
  51. make.size.mas_equalTo(CGSizeMake(self.bounds.size.width / 5.f, self.bounds.size.width / 5.f));
  52. }];
  53. [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.top.mas_equalTo(_headerImageView.mas_bottom).mas_offset(4);
  55. make.centerX.mas_equalTo(self.contentView);
  56. make.size.mas_equalTo(CGSizeMake(self.bounds.size.width - (2 * 16) - (2 * 8), ((self.bounds.size.height * (2.f / 3.f)) - self.bounds.size.width / 10.f - 40) / 3.f));
  57. }];
  58. [_sexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.mas_equalTo(_nameLabel.mas_bottom).mas_offset(8);
  60. make.left.mas_equalTo(self.contentView).mas_offset(8);
  61. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (2 * 16) - (3 * 8)) / 2.f, ((self.bounds.size.height * (2.f / 3.f)) - self.bounds.size.width / 10.f - 28) / 3.f));
  62. }];
  63. [_driverSchoolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.top.mas_equalTo(_nameLabel.mas_bottom).mas_offset(8);
  65. make.right.mas_equalTo(self.contentView).mas_offset(- 8);
  66. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (2 * 16) - (3 * 8)) / 2.f, ((self.bounds.size.height * (2.f / 3.f)) - self.bounds.size.width / 10.f - 28) / 3.f));
  67. }];
  68. [_phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.top.mas_equalTo(_sexLabel.mas_bottom).mas_offset(8);
  70. make.left.mas_equalTo(self.contentView).mas_offset(8);
  71. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (2 * 16) - (3 * 8)) / 2.f, ((self.bounds.size.height * (2.f / 3.f)) - self.bounds.size.width / 10.f - 28) / 3.f));
  72. }];
  73. [_remarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.top.mas_equalTo(_driverSchoolLabel.mas_bottom).mas_offset(8);
  75. make.right.mas_equalTo(self.contentView).mas_offset(- 8);
  76. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (2 * 16) - (3 * 8)) / 2.f, ((self.bounds.size.height * (2.f / 3.f)) - self.bounds.size.width / 10.f - 28) / 3.f));
  77. }];
  78. }
  79. - (void)updateSecVUI:(__kindof HDSectionModel *)model {
  80. NSMutableAttributedString *remarkLabelAttStr = [[NSMutableAttributedString alloc] initWithString:_remarkLabel.text];
  81. remarkLabelAttStr.yy_color = RQRedColor;
  82. [remarkLabelAttStr yy_setColor:RQContentTextColor range:[_remarkLabel.text rangeOfString:@"备注:"]];
  83. remarkLabelAttStr.yy_font = [UIFont systemFontOfSize:15];
  84. remarkLabelAttStr.yy_alignment = NSTextAlignmentCenter;
  85. _remarkLabel.attributedText = remarkLabelAttStr;
  86. }
  87. #pragma mark - Lazy Load
  88. - (UIImageView *)backgroundView {
  89. if (!_backgroundView) {
  90. _backgroundView = [[UIImageView alloc] initWithImage:[UIImage yy_imageWithColor:RQMianColor]];
  91. }
  92. return _backgroundView;
  93. }
  94. - (UIView *)contentView {
  95. if (!_contentView) {
  96. _contentView = [[UIView alloc] init];
  97. _contentView.backgroundColor = UIColor.whiteColor;
  98. _contentView.layer.cornerRadius = 5;
  99. _contentView.layer.masksToBounds = NO;
  100. _contentView.layer.shadowColor = [UIColor lightGrayColor].CGColor;
  101. _contentView.layer.shadowOffset = CGSizeMake(0, 0);
  102. _contentView.layer.shadowOpacity = 0.8;
  103. _contentView.layer.shadowRadius = 5;
  104. }
  105. return _contentView;
  106. }
  107. - (UIImageView *)headerImageView {
  108. if (!_headerImageView) {
  109. _headerImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"HeaderPlacehold"]];
  110. _headerImageView.layer.borderWidth = 4;
  111. _headerImageView.layer.borderColor = UIColor.whiteColor.CGColor;
  112. _headerImageView.layer.cornerRadius = self.bounds.size.width / 10.f;
  113. _headerImageView.layer.masksToBounds = YES;
  114. }
  115. return _headerImageView;
  116. }
  117. - (UILabel *)nameLabel {
  118. if (!_nameLabel) {
  119. _nameLabel = [[UILabel alloc] init];
  120. _nameLabel.text = @"张小凡";
  121. _nameLabel.font = [UIFont systemFontOfSize:17];
  122. _nameLabel.textAlignment = NSTextAlignmentCenter;
  123. _nameLabel.textColor = RQContentTextColor;
  124. }
  125. return _nameLabel;
  126. }
  127. - (UILabel *)sexLabel {
  128. if (!_sexLabel) {
  129. _sexLabel = [[UILabel alloc] init];
  130. _sexLabel.text = @"性别:男";
  131. _sexLabel.font = [UIFont systemFontOfSize:15];
  132. _sexLabel.textAlignment = NSTextAlignmentCenter;
  133. _sexLabel.textColor = RQContentTextColor;
  134. }
  135. return _sexLabel;
  136. }
  137. - (UILabel *)driverSchoolLabel {
  138. if (!_driverSchoolLabel) {
  139. _driverSchoolLabel = [[UILabel alloc] init];
  140. _driverSchoolLabel.text = @"驾校:金安驾校";
  141. _driverSchoolLabel.font = [UIFont systemFontOfSize:15];
  142. _driverSchoolLabel.textAlignment = NSTextAlignmentCenter;
  143. _driverSchoolLabel.textColor = RQContentTextColor;
  144. }
  145. return _driverSchoolLabel;
  146. }
  147. - (UILabel *)phoneLabel {
  148. if (!_phoneLabel) {
  149. _phoneLabel = [[UILabel alloc] init];
  150. _phoneLabel.text = @"电话:15978657321";
  151. _phoneLabel.font = [UIFont systemFontOfSize:15];
  152. _phoneLabel.textAlignment = NSTextAlignmentCenter;
  153. _phoneLabel.textColor = RQContentTextColor;
  154. }
  155. return _phoneLabel;
  156. }
  157. - (YYLabel *)remarkLabel {
  158. if (!_remarkLabel) {
  159. _remarkLabel = [[YYLabel alloc] init];
  160. _remarkLabel.text = @"备注:已考过";
  161. _remarkLabel.font = [UIFont systemFontOfSize:15];
  162. _remarkLabel.textAlignment = NSTextAlignmentCenter;
  163. _remarkLabel.textColor = RQRedColor;
  164. }
  165. return _remarkLabel;
  166. }
  167. @end