107 lines
3.1 KiB
Objective-C
107 lines
3.1 KiB
Objective-C
//
|
|
// XPMineCustomNavView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/9/23.
|
|
//
|
|
|
|
#import "XPMineUserInfoCustomNavView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
#import "UIButton+EnlargeTouchArea.h"
|
|
|
|
@interface XPMineUserInfoCustomNavView ()
|
|
///返回按钮
|
|
@property (nonatomic,strong) UIButton *backButton;
|
|
///显示文本
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
///编辑按钮
|
|
@property (nonatomic,strong) UIButton *editButton;
|
|
@end
|
|
|
|
@implementation XPMineUserInfoCustomNavView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
#pragma mark - Response
|
|
- (void)editButtonAction:(UIButton *)sender {
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineCustomNavView:didClickEditButton:)]) {
|
|
[self.delegate xPMineCustomNavView:self didClickEditButton:sender];
|
|
}
|
|
}
|
|
|
|
- (void)backButtonAction:(UIButton *)sender {
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineCustomNavView:didClickBackButton:)]) {
|
|
[self.delegate xPMineCustomNavView:self didClickBackButton:sender];
|
|
}
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.backgroundColor = [UIColor clearColor];
|
|
[self addSubview:self.backButton];
|
|
[self addSubview:self.titleLabel];
|
|
[self addSubview:self.editButton];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(15);
|
|
make.centerY.equalTo(self.mas_bottom).mas_offset(-22);
|
|
}];
|
|
|
|
[self.editButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-15);
|
|
make.centerY.equalTo(self.mas_bottom).mas_offset(-22);
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.centerY.equalTo(self.mas_bottom).mas_offset(-22);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (UIButton *)backButton {
|
|
if (!_backButton) {
|
|
_backButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_backButton setImage:[UIImage imageNamed:@"common_nav_back"] forState:UIControlStateNormal];
|
|
_backButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
|
[_backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[_backButton setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
|
|
}
|
|
return _backButton;
|
|
}
|
|
|
|
|
|
- (UIButton *)editButton {
|
|
if (!_editButton) {
|
|
_editButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_editButton setImage:[UIImage imageNamed:@"mine_user_info_edit"] forState:UIControlStateNormal];
|
|
[_editButton addTarget:self action:@selector(editButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[_editButton setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
|
|
}
|
|
return _editButton;
|
|
}
|
|
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
_titleLabel.font = [UIFont systemFontOfSize:15];
|
|
_titleLabel.textColor = [ThemeColor mainTextColor];
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
@end
|