/FasterVerificationCode

An high customizable and fast verification code view

Primary LanguageSwiftMIT LicenseMIT

FasterVerificationCode

An high customizable and fast verification code view

Version GitHub license Platform

Icon

FasterVerificationCode is an open-source fully customizable input view built to makes easier and faster the input of a verification code you provided to your users via mail/phone.

Features

  • Install it directly into your xib or storyboard.
  • Support Paste action.
  • Error handling.
  • Xlib fully customizable ui.

System Requirements

iOS 10.0 or above

Installation

As a CocoaPods Dependency

Add the following to your Podfile:

pod 'FasterVerificationCode'

Manual Installation

All of the necessary source and resource files for FasterVerificationCode are in FasterVerificationCode/Classes.

Examples

Using FasterVerificationCode is very easy and straightforward. Create a new UIView into your ViewController and insert into the Custom class field VerificationCodeView.

You can customize the appearance through the inspector tab and add your constraints.

Don't forget to:

  • add a width constraint;
  • declare it as placeholder (the view will resize at runtime following labels dimensions).

For a complete working example, check out the repo and run pod install into the project root.

Basic Implementation

@IBOutlet weak var verificationCodeView: VerificationCodeView!

override func viewDidLoad()
{
super.viewDidLoad()
verificationCodeView.setLabelNumber(6)
verificationCodeView.delegate = self
}

extension YourViewController: VerificationCodeViewDelegate
{
func verificationCodeInserted(_ text: String, isComplete: Bool)
{ 
...
}
}

VerificationCodeViewDelegate

This delegate handle the insertion of the verification code with this two method:

verificationCodeInserted

func verificationCodeInserted(_ text: String, isComplete: Bool)

This method is mandatory and is called every time the textFieldShouldEndEditing method of the textfield is called. It gives you the current text and if the text was inserted totally.

You can check the correctness of the inserted code and show a visual feedback to the user

if text == "123456"
{
.....
} else
{
// The inserted code is wrong
verificationCodeView.showError = true
}

verificationCodeChanged (optional)

@objc optional func verificationCodeChanged()

This method is optional and is called only when the user is deleting a character. It should be implemented only if you are interested in error handling and you want to reset the border color to the default color you inserted.

func verificationCodeChanged()
{
verificationCodeView.showError = false
}

Contributing

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Acknowledgements

Made with ❤️ in Milan by Antonino Musolino.