Skip to content

Simple lock screen for iOS Application ( Swift 4+, iOS 11.0+)

License

Notifications You must be signed in to change notification settings

mayckonx/MBSPasswordView

Repository files navigation

Build Status Coverage Status Platform

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

  1. Import the framework
import MBSPasswordView
  1. Go to your Storyboard/XIB -> Identity Inspector and change your UIView class and module to:
MBSPasswordView
  1. Create an outlet and link it to your view as a MBSPasswordView.
@IBOutlet weak var passwordView: MBSPasswordView!
  1. 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)")
    }
}
  1. 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.

Next improvments

  1. Support 6 digits
  2. Different kind of animations

Suggestions or feedback?

Feel free to create a pull request, open an issue or find me on Twitter.