Skip to content

Commit

Permalink
add property inputType. pod 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
薛精豪 authored and 薛精豪 committed Oct 11, 2018
1 parent be7d606 commit 9aeae58
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 9 deletions.
Binary file removed .DS_Store
Binary file not shown.
7 changes: 3 additions & 4 deletions JHVerificationCodeView.podspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

Pod::Spec.new do |s|

s.name = "JHVerificationCodeView"
s.version = "1.0.1"
s.version = "1.1.0"
s.summary = "A simple Verification Code View."
s.homepage = "https://github.com/xjh093/JHVerificationCodeView"
s.license = "MIT"
s.author = { "Haocold" => "[email protected]" }
s.platform = :ios, "7.0"
s.author = { "Haocold" => "[email protected]" }
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/xjh093/JHVerificationCodeView.git", :tag => s.version }
s.source_files = "JHVerificationCodeView/JHVerificationCodeView/*.{h,m}"
s.framework = "UIKit"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>JHVerificationCodeView.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

#import <UIKit/UIKit.h>

typedef NS_ENUM(NSUInteger, JHVCConfigInputType) {
JHVCConfigInputType_Number_Alphabet,
JHVCConfigInputType_Number,
JHVCConfigInputType_Alphabet,
};

@interface JHVCConfig : NSObject
///输入框个数
@property (assign, nonatomic) NSInteger inputBoxNumber;
Expand All @@ -52,6 +58,8 @@
@property (strong, nonatomic) UIFont *font;
///颜色
@property (strong, nonatomic) UIColor *textColor;
///输入类型:数字+字母,数字,字母. Default is 'JHVCConfigInputType_Number_Alphabet'
@property (nonatomic, assign) JHVCConfigInputType inputType;
@end

@interface JHVerificationCodeView : UIView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,21 @@ - (void)textChange:(NSNotification *)noti
NSMutableString *mstr = @"".mutableCopy;
for (int i = 0; i < text.length; ++i) {
unichar c = [text characterAtIndex:i];
if ((c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z')) {
[mstr appendFormat:@"%c",c];
if (_config.inputType == JHVCConfigInputType_Number_Alphabet) {
if ((c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z')) {
[mstr appendFormat:@"%c",c];
}
}else if (_config.inputType == JHVCConfigInputType_Number) {
if ((c >= '0' && c <= '9')) {
[mstr appendFormat:@"%c",c];
}
}else if (_config.inputType == JHVCConfigInputType_Alphabet) {
if ((c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z')) {
[mstr appendFormat:@"%c",c];
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion JHVerificationCodeView/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ - (void)jhSetupViews
config.inputBoxWidth = 33;
config.inputBoxHeight = 28;
config.tintColor = [UIColor blackColor];
config.secureTextEntry = YES;
config.secureTextEntry = NO;
config.inputBoxColor = [UIColor brownColor];
config.font = [UIFont boldSystemFontOfSize:16];
config.textColor = [UIColor brownColor];
config.inputType = JHVCConfigInputType_Number_Alphabet;

[self.view addSubview:({
JHVerificationCodeView *codeView =
Expand Down

0 comments on commit 9aeae58

Please sign in to comment.