MBSPasswordView is a custom view that provides an easy way to use a block-screen password.
Support
iOS 11.0+
Features
- Pure Swift 4
🔨 - Support 4 digits validation
🔒 - TouchID and FaceID 🤳🏻
- Light touch impact ♒︎
- Shakable view
💥 - Custom animation
💫 - Easy to use. 🤟🏻
Success Case
Invalid Case
Installation
CocoaPods
pod 'MBSPasswordView'
Carthage
MBSPasswordView is available through Carthage. To install it, simply add the following line to your Cartfile:
github "mayckonx/MBSPasswordView"
How to Use
- 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.
You can customize the view. In the sample you can see how to access the properties and change it to your preferences.
Next improvments
- Support 6 digits
- Different kind of animations
Suggestions or feedback?
Feel free to create a pull request, open an issue or find me on Twitter.