SSFloatingLabelTextField

August 25, 2021 ยท View on GitHub

Platform Swift Version License PRs Welcome

SSFloatingLabelTextField

SSFloatingLabelTextField is a small library for iOS which supports Floating labels and errors with different kind of validations. Also user can add/customise own validation and error messages.

Alt text

Features!

Main Features include :-

  • Floating Placeholder label
  • Set different validations type
  • Set Custom regex for validation or for phone number formatter
  • Check if text is valid or not and display error message

All Attributes :-

AttributeDescription
floatingLabelTextFloating Placeholder label
selectedLabelColorColor of Floating label when textfield is active
unSelectedLabelColorColor of Floating label when textfield is active
errorTextError message when text is not valid
errorTextColorColor in which error message is shown
typeSet Validation type
customValidationRegexSet Custom Regex for Validation
isPasswordToggleEnableToggle show hide password
showPasswordImageToggle image when password is visible
hidePasswordImageToggle image when password is visible

Requirements

- iOS 11.0+
- Xcode 11+

Installation

CocoaPods

  • You can use CocoaPods to install SSFloatingLabelTextField by adding it to your Podfile:

     use_frameworks!
     pod 'SSFloatingLabelTextField'
    
  • Import SSFloatingLabelTextField in your file:

     import SSFloatingLabelTextField
     
    

    Manually - Download and drop SSFloatingLabelTextField/Sources folder in your project. - Congratulations!

Usage example

In the storyboard add a UITextField and change its class to SSFloatingLabelTextField

Import SSFloatingLabelTextField

    import SSFloatingLabelTextField
    

Set text type in your View Controller file :-

    @IBOutlet weak var txtUsername: SSFloatingLabelTextField! // Add IBOutlet
    txtEmail.type = .email // Assign type as email
    txtPassword.type = .password(passwordRule: .medium) // Assign type as password 
    txtPhoneNumber.type = .phoneNumber(formatterString: nil) // Assign type as phone number (Params :- Phone number formatter default :- XXX-XXX-XXXX )
    

Check if given text field is valid or not :-

    txtUsername.isValid()
    

Find this library useful? :heart:

Support it by joining stargazers for this repository. :star:

๐Ÿค How to Contribute

Whether you're helping us fix bugs, improve the docs, or a feature request, we'd love to have you! :muscle:

Check out our Contributing Guide for ideas on contributing.

Bugs and Feedback

For bugs, feature requests, and discussion please use GitHub Issues.

Meta

  • This project is licensed under the MIT License - see the LICENSE file for details