Skip to content

Commit 6e53b80

Browse files
committed
add method
1 parent fd967df commit 6e53b80

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

.DS_Store

6 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Bucket
3+
type = "1"
4+
version = "2.0">
5+
</Bucket>

JHVerificationCodeView/JHVerificationCodeView/JHVerificationCodeView.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,9 @@ typedef NS_ENUM(NSUInteger, JHVCConfigInputType) {
8484

8585
- (instancetype)initWithFrame:(CGRect)frame config:(JHVCConfig *)config;
8686

87+
/**
88+
清空所有输入
89+
*/
90+
- (void)clear;
91+
8792
@end

JHVerificationCodeView/JHVerificationCodeView/JHVerificationCodeView.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ - (void)xx_didBecomeActive{
220220

221221
- (void)xx_textChange:(NSNotification *)noti
222222
{
223-
NSLog(@"%@",noti.object);
223+
//NSLog(@"%@",noti.object);
224224
if (_textView != noti.object) {
225225
return;
226226
}
@@ -319,4 +319,12 @@ - (void)xx_finish
319319
});
320320
}
321321

322+
#pragma mark - public
323+
324+
- (void)clear
325+
{
326+
_textView.text = @"";
327+
[[NSNotificationCenter defaultCenter] postNotificationName:UITextViewTextDidChangeNotification object:_textView];
328+
}
329+
322330
@end

JHVerificationCodeView/ViewController.m

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ - (void)viewDidLoad {
2626

2727
[self jhSetupViews];
2828

29+
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:({
30+
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
31+
button.titleLabel.font = [UIFont systemFontOfSize:16];
32+
[button setTitle:@"清空" forState:0];
33+
[button setTitleColor:[UIColor blackColor] forState:0];
34+
[button sizeToFit];
35+
[button addTarget:self action:@selector(clearAction) forControlEvents:1<<6];
36+
button;
37+
})];
2938
}
3039

3140
- (void)jhSetupViews
@@ -67,6 +76,7 @@ - (void)jhSetupViews
6776
codeView.finishBlock = ^(NSString *code) {
6877
label.text = code;
6978
};
79+
codeView.tag = 100;
7080
codeView;
7181
})];
7282
}
@@ -107,6 +117,7 @@ - (void)jhSetupViews
107117
codeView.finishBlock = ^(NSString *code) {
108118
label.text = code;
109119
};
120+
codeView.tag = 200;
110121
codeView;
111122
})];
112123
}
@@ -146,6 +157,7 @@ - (void)jhSetupViews
146157
codeView.finishBlock = ^(NSString *code) {
147158
label.text = code;
148159
};
160+
codeView.tag = 300;
149161
codeView;
150162
})];
151163
}
@@ -166,7 +178,7 @@ - (void)jhSetupViews
166178
config.tintColor = [UIColor blueColor];
167179
config.secureTextEntry = YES;
168180
config.inputBoxColor = [UIColor clearColor];
169-
config.font = [UIFont boldSystemFontOfSize:16];
181+
config.font = [UIFont boldSystemFontOfSize:20];
170182
config.textColor = [UIColor grayColor];
171183
config.inputType = JHVCConfigInputType_Alphabet;
172184

@@ -189,11 +201,27 @@ - (void)jhSetupViews
189201
codeView.finishBlock = ^(NSString *code) {
190202
label.text = code;
191203
};
204+
codeView.tag = 400;
192205
codeView;
193206
})];
194207
}
195208
}
196209

210+
211+
- (void)clearAction
212+
{
213+
JHVerificationCodeView *codeView1 = [self.view viewWithTag:100];
214+
JHVerificationCodeView *codeView2 = [self.view viewWithTag:200];
215+
JHVerificationCodeView *codeView3 = [self.view viewWithTag:300];
216+
JHVerificationCodeView *codeView4 = [self.view viewWithTag:400];
217+
218+
[codeView1 clear];
219+
[codeView2 clear];
220+
[codeView3 clear];
221+
[codeView4 clear];
222+
223+
}
224+
197225
- (void)didReceiveMemoryWarning {
198226
[super didReceiveMemoryWarning];
199227
// Dispose of any resources that can be recreated.

0 commit comments

Comments
 (0)