GithubHelp home page GithubHelp logo

manish-poddar / custominputtextfield Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vyasmayank43/custominputtextfield

0.0 1.0 0.0 24 KB

Customised UITextField with HintLabel, ErrorLabel, Divider and validations

License: MIT License

Swift 100.00%

custominputtextfield's Introduction

CustomInputTextField

Customised UITextField and UITextView with HintLabel, ErrorLabel, Divider and validations

Purpose

CustomInputTextField is a class to provide Android InputLayout functionality in iOS like HintLabel, ErrorLabel.

Supported OS & SDK Versions

Supported build target - iOS 8.0 (Xcode 7.3)

ARC Compatibility

CustomInputTextField requires ARC.

Installation

  1. Add CustomInputTextField in your Project.

  2. Drop UITextField in Storyboard or .xib and change it class to CustomInputTextField.

  3. Change values of IBInspectable as per your requirement. You can change following custom properties to show hint, divider or error message.

    hintTextColor  
    hintActiveTextColor  
    errorTextColor  
    dividerColor  
    hintFontSize  
    errorFontSize  
    errorText  
    
  4. To add InputAccessoryView on textFields give them tag greater than zero with increment for next textfield.

  5. For validation change in your ViewController make reference of textfield and in viewDidLoad write below method:

     textField.textValidationType = TextValidation.Empty
    

You can also write your own validation with following code:

    let predicate = NSPredicate(format:"self.length > 8")  // write custom predicate as per your requirement.
    textField.customPredicate = predicate
    textField.textValidationType = TextValidation.Custom

To validate text use below code:

   let check: Bool = textField.validateText()

And done....


For UITextView there is additional IBInspectable propty "hintText" for placehodler. Set it to show placeholder on textView.


Credits

Inspiration from FahimF's FloatLabelFields project.

Questions

Email: [email protected]

custominputtextfield's People

Contributors

vyasmayank43-git avatar mayankvyas avatar

Watchers

 avatar

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.