FGGTextField
Introduction
一个超级酷炫的文本输入框,继承自UITextField,依赖于AJWValidator.用于实现文本输入的实时监测。
Installtion
Manual:
Download This Project and drag the FGGTextField folder into your peroject, do not forget to ensure "copy item if need" being selected.
Cocoapods:
pod 'FGGTextField', '~> 1.0.0'
Usage
Just import the header file:import "FGGTextField.h"
FGGTextField *tf=[[FGGTextField alloc]initWithFrame:CGRectMake(10, 100, kWidth-20, 40)];
tf.placeholder=@"请输入邮箱";
tf.errorText=@"邮箱格式不对";
tf.validatorText=@"邮箱";
[self.view addSubview:tf];
tf.borderStyle=UITextBorderStyleRoundedRect;
tf.keyboardType=UIKeyboardTypeEmailAddress;
AJWValidator *validator=[AJWValidator validatorWithType:AJWValidatorTypeString];
[validator addValidationToEnsureValidEmailWithInvalidMessage:tf.errorText];
[tf ajw_attachValidator:validator];
__weak typeof(validator) weak_validator=validator;
validator.validatorStateChangedHandler=^(AJWValidatorState state){
switch (state) {
case AJWValidatorValidationStateValid:
tf.highlightState=FGGTextFieldHighlightStateValidator;
leftView.text=@"😁";
break;
case AJWValidatorValidationStateInvalid:
tf.highlightState=FGGTextFieldHighlightStateWrong;
leftView.text=@"😟";
break;
default:
break;
}
if(weak_validator.isValid){
NSLog(@"格式正确✅");
}
};
Example
1.在项目中导入:FGGTextField.h
2.创建FGGTextField的对象
FGGTextField *tf=[[FGGTextField alloc]initWithFrame:CGRectMake(50, 100, 200, 40)];
3.设置属性
tf.placeholder=@"请输入邮箱";
tf.errorText=@"邮箱格式不正确";
tf.validatorText=@"邮箱";
tf.borderStyle=UITextBorderStyleRoundedRect;
tf.keyboardType=UIKeyboardTypeEmailAddress;
4.添加到父视图
如果有问题,可以给我发邮件:newbox0512@yahoo.com
About Me
- Blog: CGPointZeero
- GitHub: Insfgg99x
- Mooc: CGPointZero
- Jianshu: CGPointZero
- Email: newbox0512@yahoo.com
I attached my code on github,touch to download:->FGGTextField
@CGPoitZero