Git Product home page Git Product logo

fggtextfield's Introduction

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(@"格式正确✅");
         }
     };

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.添加到父视图

About Me

@CGPoitZero

如果有问题,可以给我发邮件:[email protected]

fggtextfield's People

Contributors

insfgg99x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cweioo01

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.