114 lines
3.3 KiB
Objective-C
114 lines
3.3 KiB
Objective-C
//
|
|
// XPMineModifPayPwdView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/9/18.
|
|
//
|
|
|
|
#import "XPMineModifPayPwdView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
#import "UIButton+EnlargeTouchArea.h"
|
|
|
|
@interface XPMineModifPayPwdView ()
|
|
///输入框
|
|
@property (nonatomic,strong) UITextField *contentTextField;
|
|
///控制显示或者隐藏
|
|
@property (nonatomic,strong) UIButton *commandButton;
|
|
///分割线
|
|
@property (nonatomic,strong) UIView * partLineView;
|
|
@end
|
|
|
|
@implementation XPMineModifPayPwdView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Response
|
|
- (void)onClickHiddenBtn:(UIButton *)btn {
|
|
btn.selected = !btn.selected;
|
|
self.contentTextField.secureTextEntry = !self.contentTextField.secureTextEntry;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self addSubview:self.contentTextField];
|
|
[self addSubview:self.commandButton];
|
|
[self addSubview:self.partLineView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(50);
|
|
}];
|
|
|
|
[self.contentTextField mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self).offset(15);
|
|
make.top.bottom.mas_equalTo(self);
|
|
}];
|
|
|
|
[self.commandButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(self).offset(-32);
|
|
make.centerY.mas_equalTo(self.contentTextField);
|
|
make.left.mas_equalTo(self.contentTextField.mas_right).offset(10);
|
|
}];
|
|
|
|
[self.partLineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self).offset(5);
|
|
make.right.mas_equalTo(self).offset(-5);
|
|
make.bottom.mas_equalTo(self);
|
|
make.height.mas_equalTo(1);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setPlaceholder:(NSString *)placeholder {
|
|
_placeholder = placeholder;
|
|
self.contentTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSFontAttributeName : self.contentTextField.font, NSForegroundColorAttributeName : [ThemeColor secondTextColor]}];
|
|
}
|
|
|
|
|
|
- (UIView *)partLineView {
|
|
if (!_partLineView) {
|
|
_partLineView = [[UIView alloc] init];
|
|
}
|
|
return _partLineView;
|
|
}
|
|
|
|
- (UITextField *)contentTextField {
|
|
if (!_contentTextField) {
|
|
_contentTextField = [[UITextField alloc] init];
|
|
_contentTextField.secureTextEntry = YES;
|
|
_contentTextField.font = [UIFont systemFontOfSize:13];
|
|
_contentTextField.textColor = [ThemeColor mainTextColor];
|
|
_contentTextField.tintColor = [ThemeColor appMainColor];
|
|
}
|
|
return _contentTextField;
|
|
}
|
|
|
|
- (UIButton *)commandButton {
|
|
if (!_commandButton) {
|
|
_commandButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_commandButton setEnlargeEdgeWithTop:20 right:20 bottom:20 left:20];
|
|
[_commandButton addTarget:self action:@selector(onClickHiddenBtn:) forControlEvents:UIControlEventTouchUpInside];
|
|
[_commandButton setImage:[UIImage imageNamed:@"mine_setting_modif_pay_pwd_hidden"] forState:UIControlStateNormal];
|
|
[_commandButton setImage:[UIImage imageNamed:@"mine_setting_modif_pay_pwd_show"] forState:UIControlStateSelected];
|
|
_commandButton.titleLabel.font = [UIFont systemFontOfSize:12];
|
|
[_commandButton setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
|
}
|
|
return _commandButton;
|
|
}
|
|
|
|
|
|
|
|
@end
|