An high customizable and fast verification code view
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.
- Install it directly into your xib or storyboard.
- Support
Paste
action. - Error handling.
- Xlib fully customizable ui.
iOS 10.0 or above
Add the following to your Podfile:
pod 'FasterVerificationCode'
All of the necessary source and resource files for FasterVerificationCode
are in FasterVerificationCode/Classes
.
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.
@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)
{
...
}
}
This delegate handle the insertion of the verification code with this two method:
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
}
@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
}
- 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.
Made with ❤️ in Milan by Antonino Musolino.