[![CI Status](http://img.shields.io/travis/Eddie Lau/UXPasscodeField.svg?style=flat)](https://travis-ci.org/Eddie Lau/UXPasscodeField)
To run the example project, clone the repo, and run pod install
from the Example directory first.
import UIKit
import UXPasscodeField
class ViewController: UIViewController {
@IBOutlet weak var passcodeField: UXPasscodeField!
override func viewDidLoad() {
super.viewDidLoad()
passcodeField.becomeFirstResponder()
// Optional, default is 6
passcodeField.numberOfDigits = 6
// Optional, default is false
passcodeField.isSecureTextEntry = false
passcodeField.addTarget(
self,
action: #selector(ViewController.passcodeFieldDidChangeValue),
for: .valueChanged)
}
@IBAction func passcodeFieldDidChangeValue() {
print(passcodeField.passcode)
}
}
let passcodeViewController = UXPasscodeViewController.instantiate()
passcodeViewController.message = "Hello iOS developer! Please input your 4-digit code here."
passcodeViewController.numberOfDigits = 4
passcodeViewController.done { passcode in
print(passcode)
_ = passcodeViewController.resignFirstResponder()
}
iOS 8 or above.
UXPasscodeField is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "UXPasscodeField"
Eddie Lau, [email protected]
UXPasscodeField is available under the MIT license. See the LICENSE file for more info.