- TextField, which can automatically perform regular verification, and automatically prohibits the non - allowed characters to be entered.
- 能够自动自动禁止字符输入,并进行正则验证的TextField。
- iOS 6.0+
CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:
$ gem install cocoapodsTo integrate SRTextField into your Xcode project using CocoaPods, specify it in your Podfile:
platform :ios, '6.0'
use_frameworks!
pod 'SRTextField'
Then, run the following command:
$ pod installYou should open the {Project}.xcworkspace instead of the {Project}.xcodeproj after you installed anything from CocoaPods.
For more information about how to use CocoaPods, I suggest this tutorial.
- cocoapods导入:
pod 'SRTextField' - 手动导入:
- 将
SRTextField/Classes文件夹中的所有文件拽入项目中 - 导入主头文件:
#import "SRTextField.h"
- 将
- Create SRTextField, and set the properties you need.
- 创建SRTextField,并设置你需要的属性
SRTextField *phoneTextField = [[SRTextField alloc]init];
phoneTextField.regString = RegStringPhoneNumber;//正则验证是否为手机号码
phoneTextField.inputType = SRTextFieldInputTypeNumber;//只允许输入数字
phoneTextField.errorDescription = @"手机号格式错误!";//错误描述
phoneTextField.emptyDescription = @"手机号不能为空!";//是否为空描述
- Check a single SRTextField or multiple SRTextField objects, using this method.
- 检查单个的SRTextField或者多个SRTextField对象,均使用这个方法。
[SRTextChecker checkAllWidgets:@[t1] completionBlock:^(SRTextCheckerResultInfo *resultInfo) {
//输出上面填写过的错误提示
NSLog(@"%@",resultInfo.resultString);
}];