84 lines
2.4 KiB
Objective-C
Executable File
84 lines
2.4 KiB
Objective-C
Executable File
//
|
|
// BJPSWViw.m
|
|
// miliao
|
|
//
|
|
// Created by Mac on 2021/3/3.
|
|
// Copyright © 2021 miliao. All rights reserved.
|
|
//
|
|
|
|
#import "BJPSWViw.h"
|
|
|
|
@interface BJPSWViw ()
|
|
|
|
@property (nonatomic,strong) UILabel *pswLabel;
|
|
|
|
@end
|
|
|
|
@implementation BJPSWViw
|
|
|
|
#pragma mark - init method
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
if (self = [super initWithFrame:frame]) {
|
|
[self addSubview:self.pswTF];
|
|
[self addSubview:self.pswLabel];
|
|
WEAK_SELF;
|
|
[self.pswTF mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(weakSelf.mas_left);
|
|
make.right.mas_equalTo(weakSelf.mas_right);
|
|
make.top.mas_equalTo(weakSelf.mas_top);
|
|
make.bottom.mas_equalTo(weakSelf.mas_bottom);
|
|
}];
|
|
[self.pswLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(weakSelf.mas_left);
|
|
make.right.mas_equalTo(weakSelf.mas_right);
|
|
make.top.mas_equalTo(weakSelf.mas_top);
|
|
make.bottom.mas_equalTo(weakSelf.mas_bottom);
|
|
}];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - private method
|
|
- (void)pswTFChangeAction:(id)sender
|
|
{
|
|
MYLog(@"%@", self.pswTF.text);
|
|
if (self.pswTF.text.length > 0) {
|
|
NSMutableString *textStr = [[NSMutableString alloc] init];
|
|
for (int i = 0; i < self.pswTF.text.length; i++) {
|
|
[textStr appendString:@"●"];
|
|
}
|
|
self.pswLabel.text = textStr;
|
|
self.pswLabel.textColor = MHColorFromHexString(@"#333333");
|
|
}else {
|
|
self.pswLabel.text = @"请设置6-20位数字加字母密码";
|
|
self.pswLabel.textColor = MHColorFromHexString(@"#999999");
|
|
}
|
|
}
|
|
|
|
#pragma mark - getter
|
|
- (UITextField *)pswTF
|
|
{
|
|
if (!_pswTF) {
|
|
_pswTF = [[UITextField alloc] init];
|
|
_pswTF.keyboardType = UIKeyboardTypeASCIICapable;
|
|
_pswTF.autocapitalizationType = UITextAutocapitalizationTypeNone;
|
|
[_pswTF addTarget:self action:@selector(pswTFChangeAction:) forControlEvents:UIControlEventEditingChanged];
|
|
}
|
|
return _pswTF;
|
|
}
|
|
|
|
- (UILabel *)pswLabel
|
|
{
|
|
if (!_pswLabel) {
|
|
_pswLabel = [[UILabel alloc] init];
|
|
_pswLabel.textColor = MHColorFromHexString(@"#999999");
|
|
_pswLabel.font = Font(14);
|
|
_pswLabel.text = @"请设置6-20位数字加字母密码";
|
|
_pswLabel.backgroundColor = MHColorFromHexString(@"#ffffff");
|
|
}
|
|
return _pswLabel;
|
|
}
|
|
|
|
@end
|