128 lines
3.6 KiB
Objective-C
128 lines
3.6 KiB
Objective-C
//
|
|
// XPMineVerifIdentityView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/9/18.
|
|
//
|
|
|
|
#import "XPMineVerifIdentityView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
|
|
@interface XPMineVerifIdentityView ()
|
|
///
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
///分割线
|
|
@property (nonatomic, strong) UIView *lineView;
|
|
///输入框
|
|
@property (nonatomic, strong) UITextField *contentTextField;
|
|
///发送验证码
|
|
@property (nonatomic, strong) UIButton *smsCodeButton;
|
|
@end
|
|
|
|
@implementation XPMineVerifIdentityView
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Response
|
|
- (void)smsCodeButtonAction:(UIButton *)sender {
|
|
if (self.smsCodeBlock) {
|
|
self.smsCodeBlock(sender);
|
|
}
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self addSubview:self.stackView];
|
|
[self addSubview:self.lineView];
|
|
|
|
[self.stackView addArrangedSubview:self.contentTextField];
|
|
[self.stackView addArrangedSubview:self.smsCodeButton];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(50);
|
|
}];
|
|
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self).offset(15);
|
|
make.right.mas_equalTo(self).offset(-32);
|
|
make.top.bottom.mas_equalTo(self);
|
|
}];
|
|
|
|
[self.lineView 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)setType:(XPMineVerifIdentityType)type {
|
|
_type = type;
|
|
switch (_type) {
|
|
case XPMineVerifIdentityType_Phone:
|
|
self.smsCodeButton.hidden = YES;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
- (void)setPlaceholder:(NSString *)placeholder {
|
|
_placeholder = placeholder;
|
|
self.contentTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSFontAttributeName : self.contentTextField.font, NSForegroundColorAttributeName : [ThemeColor secondTextColor]}];
|
|
}
|
|
|
|
- (UIStackView *)stackView {
|
|
if (!_stackView) {
|
|
_stackView = [[UIStackView alloc] init];
|
|
_stackView.axis = UILayoutConstraintAxisHorizontal;
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
_stackView.alignment = UIStackViewAlignmentCenter;
|
|
_stackView.spacing = 10;
|
|
}
|
|
return _stackView;
|
|
}
|
|
|
|
- (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 *)smsCodeButton {
|
|
if (!_smsCodeButton) {
|
|
_smsCodeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_smsCodeButton setTitle:@"发送验证码" forState:UIControlStateNormal];
|
|
[_smsCodeButton setTitleColor:[ThemeColor appMainColor] forState:UIControlStateNormal];
|
|
[_smsCodeButton setTitleColor:[ThemeColor appEmphasizeColor] forState:UIControlStateDisabled];
|
|
_smsCodeButton.titleLabel.font = [UIFont systemFontOfSize:12];
|
|
_smsCodeButton.layer.masksToBounds = YES;
|
|
_smsCodeButton.layer.cornerRadius = 10;
|
|
[_smsCodeButton addTarget:self action:@selector(smsCodeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[_smsCodeButton setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
|
}
|
|
return _smsCodeButton;
|
|
}
|
|
|
|
@end
|