HJFullTimeDetailHeaderView.m 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. //
  2. // HJFullTimeDetailHeaderView.m
  3. // HappyJob
  4. //
  5. // Created by 张晓光 on 2019/8/16.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJFullTimeDetailHeaderView.h"
  9. #import "HJPositionDetailDataBox.h"
  10. @interface HJFullTimeDetailHeaderView ()
  11. @property (nonatomic, strong) UIView *topView;//顶部的view
  12. @property (nonatomic, strong) UIView *titleView;//标题
  13. @property (nonatomic, strong) UIView *salaryView;//薪资
  14. @property (nonatomic, strong) UIView *lineView1;
  15. @property (nonatomic, strong) UILabel *feeLabel;//反费
  16. @property (nonatomic, strong) UIView *femaleView;//反费
  17. @property (nonatomic, strong) UIView *maleView;//反费
  18. @property (nonatomic, strong) UIView *peopleView;//招聘人数
  19. @property (nonatomic, strong) UIView *timeView;//时间
  20. @property (nonatomic, strong) UIView *lineView2;
  21. @end
  22. @implementation HJFullTimeDetailHeaderView
  23. - (instancetype)initWithFrame:(CGRect)frame {
  24. if (self = [super initWithFrame:frame])
  25. {
  26. self.backgroundColor = [UIColor whiteColor];
  27. }
  28. return self;
  29. }
  30. - (void)configurationFullTimeDetailHeaderViewData:(NSDictionary *)data andCollectionButton:(UIButton *)collectionBtn {
  31. for (UIView *subViews in self.subviews)
  32. {
  33. [subViews removeFromSuperview];
  34. }
  35. self.titleView = data[kHJPositionKeyTitle];
  36. self.salaryView = data[kHJPositionKeySalary];
  37. self.femaleView = data[kHJPositionKeyFemaleReward];
  38. self.maleView = data[kHJPositionKeyMaleReward];
  39. self.peopleView = data[kHJPositionKeyRecruitAndDate];
  40. self.timeView = data[kHJPositionKeyTime];
  41. [self addSubview:self.topView];
  42. [self.topView addSubview:self.lineView1];
  43. if (!self.maleView.hidden)
  44. {
  45. [self.topView addSubview:self.maleView];
  46. }
  47. if (!self.femaleView.hidden)
  48. {
  49. [self.topView addSubview:self.femaleView];
  50. }
  51. [self.topView addSubview:self.titleView];
  52. [self.topView addSubview:self.salaryView];
  53. [self.topView addSubview:self.peopleView];
  54. [self.topView addSubview:self.timeView];
  55. [self.topView addSubview:self.lineView2];
  56. [self.topView addSubview:collectionBtn];
  57. [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.top.equalTo(self.mas_top).with.offset(0);
  59. make.left.right.equalTo(self).offset(0);
  60. make.bottom.equalTo(self.mas_bottom).offset(0);
  61. }];
  62. [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.top.equalTo(self.topView).with.offset(15);
  64. make.left.equalTo(self.topView).with.offset(15);
  65. }];
  66. [self.salaryView mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.centerY.equalTo(self.titleView);
  68. make.right.equalTo(self.topView).with.offset(-15);
  69. make.left.greaterThanOrEqualTo(self.titleView.mas_right);
  70. make.width.mas_greaterThanOrEqualTo(140);
  71. }];
  72. [self.peopleView mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.left.equalTo(self.titleView);
  74. make.top.equalTo(self.titleView.mas_bottom).with.offset(6);
  75. }];
  76. [self.timeView mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.right.equalTo(self.salaryView);
  78. make.centerY.equalTo(self.peopleView);
  79. }];
  80. [self.lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.left.equalTo(self.topView).offset(0);
  82. make.right.equalTo(self.topView).offset(0);
  83. make.height.mas_equalTo(1);
  84. make.top.equalTo(self.peopleView.mas_bottom).offset(15);
  85. }];
  86. [collectionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.top.equalTo(self.lineView1.mas_bottom).offset(9);
  88. make.right.equalTo(self.topView.mas_right).offset(-15);
  89. }];
  90. [self.lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.left.equalTo(self.topView).offset(0);
  92. make.right.equalTo(self.topView).offset(0);
  93. make.height.mas_equalTo(1);
  94. make.top.equalTo(collectionBtn.mas_bottom).offset(9);
  95. make.bottom.equalTo(self.topView.mas_bottom).offset(0);
  96. }];
  97. if ([self.topView.subviews indexOfObject:self.maleView] != NSNotFound)
  98. {
  99. [self.topView addSubview:self.feeLabel];
  100. [self.feeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.top.equalTo(self.lineView1.mas_bottom).with.offset(10);
  102. make.left.equalTo(self.titleView);
  103. make.size.mas_offset(CGSizeMake(35, 20));
  104. make.bottom.equalTo(self.topView.mas_bottom).offset(-15);
  105. }];
  106. [self.maleView mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.centerY.equalTo(self.feeLabel);
  108. make.left.equalTo(self.feeLabel.mas_right).offset(10);
  109. }];
  110. if ([self.topView.subviews indexOfObject:self.femaleView] != NSNotFound)
  111. {
  112. [self.femaleView mas_makeConstraints:^(MASConstraintMaker *make) {
  113. make.centerY.equalTo(self.maleView);
  114. make.left.equalTo(self.maleView.mas_right).with.offset(5);
  115. }];
  116. }
  117. }
  118. else
  119. {
  120. if ([self.topView.subviews indexOfObject:self.femaleView] != NSNotFound)
  121. {
  122. [self.topView addSubview:self.feeLabel];
  123. [self.feeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  124. make.top.equalTo(self.lineView1.mas_bottom).with.offset(10);
  125. make.left.equalTo(self.titleView);
  126. make.size.mas_offset(CGSizeMake(35, 20));
  127. make.bottom.equalTo(self.topView.mas_bottom).offset(-15);
  128. }];
  129. [self.femaleView mas_makeConstraints:^(MASConstraintMaker *make) {
  130. make.centerY.equalTo(self.feeLabel);
  131. make.left.equalTo(self.feeLabel.mas_right).offset(10);
  132. }];
  133. }
  134. }
  135. }
  136. #pragma mark - lazy
  137. - (UIView *)topView {
  138. if (_topView == nil)
  139. {
  140. _topView = [[UIView alloc]init];
  141. _topView.backgroundColor = [UIColor whiteColor];
  142. }
  143. return _topView;
  144. }
  145. - (UILabel *)feeLabel {
  146. if (_feeLabel == nil)
  147. {
  148. _feeLabel = [[UILabel alloc]init];
  149. _feeLabel.text = @"奖励";
  150. _feeLabel.textAlignment = NSTextAlignmentCenter;
  151. _feeLabel.layer.cornerRadius =3;
  152. _feeLabel.layer.masksToBounds = YES;
  153. _feeLabel.font = [UIFont systemFontOfSize:12];
  154. _feeLabel.textColor = [UIColor whiteColor];
  155. _feeLabel.backgroundColor = COLOR_FE7235;
  156. }
  157. return _feeLabel;
  158. }
  159. - (UIView *)lineView1 {
  160. if (_lineView1 == nil)
  161. {
  162. _lineView1 = [[UIView alloc] init];
  163. _lineView1.backgroundColor = COLOR_EEEEEE;
  164. }
  165. return _lineView1;
  166. }
  167. - (UIView *)lineView2 {
  168. if (_lineView2 == nil)
  169. {
  170. _lineView2 = [[UIView alloc] init];
  171. _lineView2.backgroundColor = COLOR_EEEEEE;
  172. }
  173. return _lineView2;
  174. }
  175. @end