增加替换所有秘文操作

This commit is contained in:
BearXR
2020-01-20 15:31:03 +08:00
parent a75ffad7f5
commit 8ba4f21ff6
2 changed files with 42 additions and 12 deletions

View File

@@ -401,7 +401,9 @@
_boxInputView.ifNeedSecurity = YES;//need
_boxInputView.boxFlowLayout.itemSize = CGSizeMake(XX_6(52), XX_6(52));
_boxInputView.customCellProperty = cellProperty;
[_boxInputView loadAndPrepareViewWithBeginEdit:YES];
[_boxInputView loadAndPrepareViewWithBeginEdit:NO];
[_boxInputView reloadInputString:@"5678"];
return _boxInputView;
}

View File

@@ -150,7 +150,7 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
{
if (![self.textView.text isEqualToString:value]) {
self.textView.text = value;
[self textDidChange:self.textView];
[self baseTextDidChange:self.textView manualInvoke:YES];
}
}
@@ -196,7 +196,15 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
}
#pragma mark - UITextFieldDidChange
- (void)textDidChange:(UITextField *)textField{
- (void)textDidChange:(UITextField *)textField {
[self baseTextDidChange:textField manualInvoke:NO];
}
/**
* textDidChange
* manualInvoke
*/
- (void)baseTextDidChange:(UITextField *)textField manualInvoke:(BOOL)manualInvoke {
__weak typeof(self) weakSelf = self;
@@ -237,7 +245,15 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
[strongSelf.valueArr addObject:substring];
}];
[self delaySecurityProcess];
if (self.ifNeedSecurity) {
if (manualInvoke) {
//
[self delaySecurityProcessAll];
}else {
//
[self delaySecurityProcessLastOne];
}
}
}
}
[_mainCollectionView reloadData];
@@ -253,7 +269,7 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
- (void)setSecurityShow:(BOOL)isShow index:(NSInteger)index
{
if (index < 0) {
NSAssert(NO, @"index必须大于0");
NSAssert(NO, @"index必须大于等于0");
return;
}
@@ -291,6 +307,10 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
#pragma mark - Asterisk
//
/**
*
* needEqualToCount
*/
- (void)replaceValueArrToAsteriskWithIndex:(NSInteger)index needEqualToCount:(BOOL)needEqualToCount
{
if (!self.ifNeedSecurity) {
@@ -304,15 +324,11 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
[self setSecurityShow:YES index:index];
}
//
- (void)delaySecurityProcess
//
- (void)delaySecurityProcessLastOne
{
if (!self.ifNeedSecurity) {
return;
}
__weak __typeof(self)weakSelf = self;
[self delayAfter:_securityDelay dealBlock:^{
[self delayAfter:self.securityDelay dealBlock:^{
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (strongSelf.valueArr.count > 0) {
[strongSelf replaceValueArrToAsteriskWithIndex:strongSelf.valueArr.count-1 needEqualToCount:YES];
@@ -323,6 +339,18 @@ typedef NS_ENUM(NSInteger, CRBoxTextChangeType) {
}];
}
//
- (void)delaySecurityProcessAll
{
__weak __typeof(self)weakSelf = self;
[self.valueArr enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
__strong __typeof(weakSelf)strongSelf = weakSelf;
[strongSelf replaceValueArrToAsteriskWithIndex:idx needEqualToCount:NO];
}];
[self.mainCollectionView reloadData];
}
#pragma mark - DelayBlock
- (void)delayAfter:(CGFloat)delayTime dealBlock:(void (^)(void))dealBlock
{