| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- //
- // HJMeResumeView.m
- // HappyJob
- //
- // Created by Bob on 2019/4/18.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "HJMeResumeView.h"
- @interface HJMeResumeView ()
- @property (nonatomic, strong) UIView *resumeView;
- @property (nonatomic, strong) UILabel *titleLabel;
- @property (nonatomic, strong) UIButton *titleIcon;
- @property (nonatomic, strong) UILabel *stateLabel;
- @property (nonatomic, strong) UIButton *editButton;
- @property (nonatomic, strong) UIImageView *progressImageV;
- @property (nonatomic, strong) UILabel *progressLabel;
- @end
- @implementation HJMeResumeView
- - (instancetype)init {
-
- if (self = [super init])
- {
- self.backgroundColor = COLOR_F5F5F5;
- [self addSubview:self.resumeView];
- [self.resumeView addSubview:self.titleLabel];
- [self.resumeView addSubview:self.titleIcon];
- [self.resumeView addSubview:self.stateLabel];
- [self.resumeView addSubview:self.editButton];
- [self.resumeView addSubview:self.progressImageV];
- [self.progressImageV addSubview:self.progressLabel];
-
- // 默认是未认证状态,该赋值放在布局方法后调用,因为要在set方法中根据它的状态进行布局调整。
- self.percent = 0;
-
- UITapGestureRecognizer *tapGesturRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(containerViewTapAction:)];
- [self addGestureRecognizer:tapGesturRecognizer];
- [self makeConstraints];
- }
- return self;
- }
- - (void)makeConstraints {
-
- [self.resumeView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.leading.equalTo(self.mas_leading).offset(0);
- make.trailing.equalTo(self.mas_trailing).offset(0);
- make.top.equalTo(self.mas_top).offset(10);
- make.bottom.equalTo(self.mas_bottom).offset(-10);
- }];
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.leading.equalTo(self.resumeView.mas_leading).offset(25);
- make.top.equalTo(self.resumeView.mas_top).offset(20);
- }];
- [self.titleIcon mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.centerY.equalTo(self.titleLabel);
- make.leading.equalTo(self.titleLabel.mas_trailing).offset(10);
- make.height.mas_equalTo(40);
- }];
-
- [self.stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.titleLabel.mas_bottom).offset(14);
- make.leading.equalTo(self.titleLabel);
- make.trailing.equalTo(self.progressImageV.mas_leading).offset(-5);
- }];
-
- [self.editButton mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.leading.equalTo(self.titleLabel);
- make.top.equalTo(self.stateLabel.mas_bottom).offset(10);
- make.size.mas_offset(CGSizeMake(70, 26));
- }];
-
- [self.progressImageV mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.resumeView.mas_top).offset(20);
- make.bottom.equalTo(self.resumeView.mas_bottom).offset(-20);
- make.trailing.equalTo(self.resumeView.mas_trailing).offset(-30);
- make.size.mas_offset(CGSizeMake(80, 80));
- }];
- [self.progressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.center.equalTo(self.progressImageV);
- }];
-
- }
- #pragma mark - event response
- - (void)containerViewTapAction:(id)sender {
-
- if ([self.delegate respondsToSelector:@selector(meResumeViewDidForward:)])
- {
- [self.delegate meResumeViewDidForward:self];
- }
- }
- - (void)editButtonClicked:(UIButton *)sender {
-
- if ([self.delegate respondsToSelector:@selector(meResumeViewDidEditBtnForward:)])
- {
- [self.delegate meResumeViewDidEditBtnForward:self];
- }
- }
- #pragma mark - getters and setters
- - (void)setPercent:(CGFloat)percent {
-
- _percent = percent;
- if (percent < 100)
- {
- self.stateLabel.text = @"完善简历可以获得更多面试机会!";
- _titleIcon.hidden = YES;
- }
- else
- {
- self.stateLabel.text = @"快去看看有没有心仪的岗位吧!";
- [_editButton setTitle:@"去看看" forState:UIControlStateNormal];
- _titleIcon.hidden = NO;
- }
- self.progressLabel.text = [NSString stringWithFormat:@"%@%%",@(percent)];
- self.progressImageV.image = [UIImage imageNamed:[NSString stringWithFormat:@"percent%@",@(percent)]];
-
- }
- - (UIView *)resumeView {
-
- if (_resumeView == nil)
- {
- _resumeView = [[UIView alloc] init];
- _resumeView.backgroundColor = [UIColor whiteColor];
- }
- return _resumeView;
- }
- - (UILabel *)titleLabel {
-
- if (_titleLabel == nil)
- {
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.textColor = COLOR_000000;
- _titleLabel.font = [UIFont boldSystemFontOfSize:17];
- _titleLabel.text = @"我的简历";
- }
- return _titleLabel;
- }
- - (UIButton *)titleIcon {
-
- if (_titleIcon == nil)
- {
- _titleIcon = [UIButton buttonWithType:UIButtonTypeCustom];
- [_titleIcon setTitle:@"编辑简历" forState:UIControlStateNormal];
- _titleIcon.titleLabel.font = [UIFont systemFontOfSize:12];
- [_titleIcon setTitleColor:COLOR_999999 forState:UIControlStateNormal];
- [_titleIcon setImage:[UIImage imageNamed:@"me_resume_icon"] forState:UIControlStateNormal];
- [_titleIcon addTarget:self action:@selector(containerViewTapAction:) forControlEvents:UIControlEventTouchUpInside];
- [_titleIcon layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
- }
- return _titleIcon;
- }
- - (UILabel *)stateLabel {
-
- if (_stateLabel == nil)
- {
- _stateLabel = [[UILabel alloc] init];
- _stateLabel.textColor = COLOR_000000;
- _stateLabel.adjustsFontSizeToFitWidth = YES;
- _stateLabel.font = [UIFont systemFontOfSize:14];
- }
- return _stateLabel;
- }
- - (UIButton *)editButton {
-
- if (_editButton == nil)
- {
- _editButton = [UIButton buttonWithType:UIButtonTypeCustom];
- _editButton.titleLabel.font = [UIFont systemFontOfSize:14];
- _editButton.layer.cornerRadius = 5;
- _editButton.layer.masksToBounds = YES;
- _editButton.layer.borderWidth = 1;
- _editButton.layer.borderColor = COLOR_0177FF.CGColor;
- [_editButton setTitle:@"去完善" forState:UIControlStateNormal];
- [_editButton setTitleColor:COLOR_0177FF forState:UIControlStateNormal];
- [_editButton addTarget:self action:@selector(editButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _editButton;
- }
- - (UIImageView *)progressImageV {
-
- if (_progressImageV == nil)
- {
- _progressImageV = [[UIImageView alloc]init];
- _progressImageV.contentMode = UIViewContentModeScaleAspectFit;
- _progressImageV.clipsToBounds = YES;
- }
- return _progressImageV;
- }
- - (UILabel *)progressLabel {
-
- if (_progressLabel == nil)
- {
- _progressLabel = [[UILabel alloc] init];
- _progressLabel.textColor = COLOR_999999;
- _progressLabel.font = [UIFont boldSystemFontOfSize:17];
- }
- return _progressLabel;
- }
- @end
|