Skip to content

Commit 9aeae58

Browse files
薛精豪薛精豪
authored andcommitted
add property inputType. pod 1.1.0
1 parent be7d606 commit 9aeae58

File tree

8 files changed

+50
-9
lines changed

8 files changed

+50
-9
lines changed

.DS_Store

-6 KB
Binary file not shown.

JHVerificationCodeView.podspec

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11

22
Pod::Spec.new do |s|
3-
43
s.name = "JHVerificationCodeView"
5-
s.version = "1.0.1"
4+
s.version = "1.1.0"
65
s.summary = "A simple Verification Code View."
76
s.homepage = "https://github.com/xjh093/JHVerificationCodeView"
87
s.license = "MIT"
9-
s.author = { "Haocold" => "[email protected]" }
10-
s.platform = :ios, "7.0"
8+
s.author = { "Haocold" => "[email protected]" }
9+
s.platform = :ios, "8.0"
1110
s.source = { :git => "https://github.com/xjh093/JHVerificationCodeView.git", :tag => s.version }
1211
s.source_files = "JHVerificationCodeView/JHVerificationCodeView/*.{h,m}"
1312
s.framework = "UIKit"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>JHVerificationCodeView.xcscheme</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
</dict>
14+
</plist>

JHVerificationCodeView/JHVerificationCodeView/JHVerificationCodeView.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929

3030
#import <UIKit/UIKit.h>
3131

32+
typedef NS_ENUM(NSUInteger, JHVCConfigInputType) {
33+
JHVCConfigInputType_Number_Alphabet,
34+
JHVCConfigInputType_Number,
35+
JHVCConfigInputType_Alphabet,
36+
};
37+
3238
@interface JHVCConfig : NSObject
3339
///输入框个数
3440
@property (assign, nonatomic) NSInteger inputBoxNumber;
@@ -52,6 +58,8 @@
5258
@property (strong, nonatomic) UIFont *font;
5359
///颜色
5460
@property (strong, nonatomic) UIColor *textColor;
61+
///输入类型:数字+字母,数字,字母. Default is 'JHVCConfigInputType_Number_Alphabet'
62+
@property (nonatomic, assign) JHVCConfigInputType inputType;
5563
@end
5664

5765
@interface JHVerificationCodeView : UIView

JHVerificationCodeView/JHVerificationCodeView/JHVerificationCodeView.m

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,21 @@ - (void)textChange:(NSNotification *)noti
160160
NSMutableString *mstr = @"".mutableCopy;
161161
for (int i = 0; i < text.length; ++i) {
162162
unichar c = [text characterAtIndex:i];
163-
if ((c >= '0' && c <= '9') ||
164-
(c >= 'A' && c <= 'Z') ||
165-
(c >= 'a' && c <= 'z')) {
166-
[mstr appendFormat:@"%c",c];
163+
if (_config.inputType == JHVCConfigInputType_Number_Alphabet) {
164+
if ((c >= '0' && c <= '9') ||
165+
(c >= 'A' && c <= 'Z') ||
166+
(c >= 'a' && c <= 'z')) {
167+
[mstr appendFormat:@"%c",c];
168+
}
169+
}else if (_config.inputType == JHVCConfigInputType_Number) {
170+
if ((c >= '0' && c <= '9')) {
171+
[mstr appendFormat:@"%c",c];
172+
}
173+
}else if (_config.inputType == JHVCConfigInputType_Alphabet) {
174+
if ((c >= 'A' && c <= 'Z') ||
175+
(c >= 'a' && c <= 'z')) {
176+
[mstr appendFormat:@"%c",c];
177+
}
167178
}
168179
}
169180

JHVerificationCodeView/ViewController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ - (void)jhSetupViews
4141
config.inputBoxWidth = 33;
4242
config.inputBoxHeight = 28;
4343
config.tintColor = [UIColor blackColor];
44-
config.secureTextEntry = YES;
44+
config.secureTextEntry = NO;
4545
config.inputBoxColor = [UIColor brownColor];
4646
config.font = [UIFont boldSystemFontOfSize:16];
4747
config.textColor = [UIColor brownColor];
48+
config.inputType = JHVCConfigInputType_Number_Alphabet;
4849

4950
[self.view addSubview:({
5051
JHVerificationCodeView *codeView =

0 commit comments

Comments
 (0)