MBSPasswordView is a custom view that provides an easy way to use a block-screen password.
iOS 11.0+
- Pure Swift 4 🔨
- Support 4 digits validation 🔒
- TouchID and FaceID 🤳🏻
- Light touch impact ♒︎
- Shakable view 💥
- Custom animation 💫
- Easy to use. 🤟🏻
pod 'MBSPasswordView'
MBSPasswordView is available through Carthage. To install it, simply add the following line to your Cartfile:
github "mayckonx/MBSPasswordView"
- Import the framework
import MBSPasswordView
- Go to your Storyboard/XIB -> Identity Inspector and change your UIView class and module to:
MBSPasswordView
- Create an outlet and link it to your view as a MBSPasswordView.
@IBOutlet weak var passwordView: MBSPasswordView!
- Implement the protocol to get the password result.
extension ViewController: MBSPasswordDelegate {
func password(_ result: [String]) { // optional
print("Password:\(result)")
}
func passwordFromBiometrics(_ result: Result<[String]>) { // optional
print("Result:\(result)")
}
}
- Set the delegate in your viewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
passwordView?.delegate = self
passwordView?.titleToRequestAuthentication = "Please, identify your self!"
passwordView?.start(enableBiometrics: true)
}
If you want, you can also check if the device supports FaceID/TouchID using:
passwordView?.isTouchIDAvailable()
passwordView?.isFaceIDAvailable()
That's it. If you enable biometrics, you get the password and automatically request the TouchID/FaceID every time. You just need to pass enableBiometrics: true on the start method. 😎 It's done brah!
You can customize the view. In the sample you can see how to access the properties and change it to your preferences.
- Support 6 digits
- Different kind of animations
Feel free to create a pull request, open an issue or find me on Twitter.