HJMeResumeView.m 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. //
  2. // HJMeResumeView.m
  3. // HappyJob
  4. //
  5. // Created by Bob on 2019/4/18.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJMeResumeView.h"
  9. @interface HJMeResumeView ()
  10. @property (nonatomic, strong) UIView *resumeView;
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @property (nonatomic, strong) UIButton *titleIcon;
  13. @property (nonatomic, strong) UILabel *stateLabel;
  14. @property (nonatomic, strong) UIButton *editButton;
  15. @property (nonatomic, strong) UIImageView *progressImageV;
  16. @property (nonatomic, strong) UILabel *progressLabel;
  17. @end
  18. @implementation HJMeResumeView
  19. - (instancetype)init {
  20. if (self = [super init])
  21. {
  22. self.backgroundColor = COLOR_F5F5F5;
  23. [self addSubview:self.resumeView];
  24. [self.resumeView addSubview:self.titleLabel];
  25. [self.resumeView addSubview:self.titleIcon];
  26. [self.resumeView addSubview:self.stateLabel];
  27. [self.resumeView addSubview:self.editButton];
  28. [self.resumeView addSubview:self.progressImageV];
  29. [self.progressImageV addSubview:self.progressLabel];
  30. // 默认是未认证状态,该赋值放在布局方法后调用,因为要在set方法中根据它的状态进行布局调整。
  31. self.percent = 0;
  32. UITapGestureRecognizer *tapGesturRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(containerViewTapAction:)];
  33. [self addGestureRecognizer:tapGesturRecognizer];
  34. [self makeConstraints];
  35. }
  36. return self;
  37. }
  38. - (void)makeConstraints {
  39. [self.resumeView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.leading.equalTo(self.mas_leading).offset(0);
  41. make.trailing.equalTo(self.mas_trailing).offset(0);
  42. make.top.equalTo(self.mas_top).offset(10);
  43. make.bottom.equalTo(self.mas_bottom).offset(-10);
  44. }];
  45. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.leading.equalTo(self.resumeView.mas_leading).offset(25);
  47. make.top.equalTo(self.resumeView.mas_top).offset(20);
  48. }];
  49. [self.titleIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.centerY.equalTo(self.titleLabel);
  51. make.leading.equalTo(self.titleLabel.mas_trailing).offset(10);
  52. make.height.mas_equalTo(40);
  53. }];
  54. [self.stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.top.equalTo(self.titleLabel.mas_bottom).offset(14);
  56. make.leading.equalTo(self.titleLabel);
  57. make.trailing.equalTo(self.progressImageV.mas_leading).offset(-5);
  58. }];
  59. [self.editButton mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.leading.equalTo(self.titleLabel);
  61. make.top.equalTo(self.stateLabel.mas_bottom).offset(10);
  62. make.size.mas_offset(CGSizeMake(70, 26));
  63. }];
  64. [self.progressImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.equalTo(self.resumeView.mas_top).offset(20);
  66. make.bottom.equalTo(self.resumeView.mas_bottom).offset(-20);
  67. make.trailing.equalTo(self.resumeView.mas_trailing).offset(-30);
  68. make.size.mas_offset(CGSizeMake(80, 80));
  69. }];
  70. [self.progressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.center.equalTo(self.progressImageV);
  72. }];
  73. }
  74. #pragma mark - event response
  75. - (void)containerViewTapAction:(id)sender {
  76. if ([self.delegate respondsToSelector:@selector(meResumeViewDidForward:)])
  77. {
  78. [self.delegate meResumeViewDidForward:self];
  79. }
  80. }
  81. - (void)editButtonClicked:(UIButton *)sender {
  82. if ([self.delegate respondsToSelector:@selector(meResumeViewDidEditBtnForward:)])
  83. {
  84. [self.delegate meResumeViewDidEditBtnForward:self];
  85. }
  86. }
  87. #pragma mark - getters and setters
  88. - (void)setPercent:(CGFloat)percent {
  89. _percent = percent;
  90. if (percent < 100)
  91. {
  92. self.stateLabel.text = @"完善简历可以获得更多面试机会!";
  93. _titleIcon.hidden = YES;
  94. }
  95. else
  96. {
  97. self.stateLabel.text = @"快去看看有没有心仪的岗位吧!";
  98. [_editButton setTitle:@"去看看" forState:UIControlStateNormal];
  99. _titleIcon.hidden = NO;
  100. }
  101. self.progressLabel.text = [NSString stringWithFormat:@"%@%%",@(percent)];
  102. self.progressImageV.image = [UIImage imageNamed:[NSString stringWithFormat:@"percent%@",@(percent)]];
  103. }
  104. - (UIView *)resumeView {
  105. if (_resumeView == nil)
  106. {
  107. _resumeView = [[UIView alloc] init];
  108. _resumeView.backgroundColor = [UIColor whiteColor];
  109. }
  110. return _resumeView;
  111. }
  112. - (UILabel *)titleLabel {
  113. if (_titleLabel == nil)
  114. {
  115. _titleLabel = [[UILabel alloc] init];
  116. _titleLabel.textColor = COLOR_000000;
  117. _titleLabel.font = [UIFont boldSystemFontOfSize:17];
  118. _titleLabel.text = @"我的简历";
  119. }
  120. return _titleLabel;
  121. }
  122. - (UIButton *)titleIcon {
  123. if (_titleIcon == nil)
  124. {
  125. _titleIcon = [UIButton buttonWithType:UIButtonTypeCustom];
  126. [_titleIcon setTitle:@"编辑简历" forState:UIControlStateNormal];
  127. _titleIcon.titleLabel.font = [UIFont systemFontOfSize:12];
  128. [_titleIcon setTitleColor:COLOR_999999 forState:UIControlStateNormal];
  129. [_titleIcon setImage:[UIImage imageNamed:@"me_resume_icon"] forState:UIControlStateNormal];
  130. [_titleIcon addTarget:self action:@selector(containerViewTapAction:) forControlEvents:UIControlEventTouchUpInside];
  131. [_titleIcon layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
  132. }
  133. return _titleIcon;
  134. }
  135. - (UILabel *)stateLabel {
  136. if (_stateLabel == nil)
  137. {
  138. _stateLabel = [[UILabel alloc] init];
  139. _stateLabel.textColor = COLOR_000000;
  140. _stateLabel.adjustsFontSizeToFitWidth = YES;
  141. _stateLabel.font = [UIFont systemFontOfSize:14];
  142. }
  143. return _stateLabel;
  144. }
  145. - (UIButton *)editButton {
  146. if (_editButton == nil)
  147. {
  148. _editButton = [UIButton buttonWithType:UIButtonTypeCustom];
  149. _editButton.titleLabel.font = [UIFont systemFontOfSize:14];
  150. _editButton.layer.cornerRadius = 5;
  151. _editButton.layer.masksToBounds = YES;
  152. _editButton.layer.borderWidth = 1;
  153. _editButton.layer.borderColor = COLOR_0177FF.CGColor;
  154. [_editButton setTitle:@"去完善" forState:UIControlStateNormal];
  155. [_editButton setTitleColor:COLOR_0177FF forState:UIControlStateNormal];
  156. [_editButton addTarget:self action:@selector(editButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
  157. }
  158. return _editButton;
  159. }
  160. - (UIImageView *)progressImageV {
  161. if (_progressImageV == nil)
  162. {
  163. _progressImageV = [[UIImageView alloc]init];
  164. _progressImageV.contentMode = UIViewContentModeScaleAspectFit;
  165. _progressImageV.clipsToBounds = YES;
  166. }
  167. return _progressImageV;
  168. }
  169. - (UILabel *)progressLabel {
  170. if (_progressLabel == nil)
  171. {
  172. _progressLabel = [[UILabel alloc] init];
  173. _progressLabel.textColor = COLOR_999999;
  174. _progressLabel.font = [UIFont boldSystemFontOfSize:17];
  175. }
  176. return _progressLabel;
  177. }
  178. @end