酷炫的文本输入框FGGTextField

#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:

1
pod 'FGGTextField', '~> 1.0.0'

##Usage
Just import the header file:import "FGGTextField.h"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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

I attached my code on github,touch to download:->FGGTextField


@CGPoitZero