This project gives you a passcode control that can be dropped into any iOS app. It behaves exactly like the passcode screens that can be seen by going to Settings > General > Passcode Lock.
- Native iOS look and feel
- Masks pin entry with bullet characters (If you want a secured entry)
- Easily customizable
- Provide custom text to be displayed on the passcode entry view
- Block-based passcode verification
PinView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'PinEntryField'
Drag the PinView file into your project and voilà
import PinView
Create the view inside viewDidLoad
let passcodeView = CodeView(numberOfPin: 4, codeStyle: .line)
passcodeView.isSecureTextEntry = true
//Conform to the protocol `PinInputDelegate` so you will know when the pin entery has been completed
passcodeView.delegate = self
passcodeView.frame = ??
//Yea that is all you have to do!!
The only extra protcol stub is
func didFinishInput(_ inputView: CodeView, didFinishWith text: String) {
print(text)
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
Attribute | Description |
---|---|
isSecureTextEntry | Just like it says (secure entry) it will mask out the text |
boxSize | Custom size for the boxes of type CGSize |
codeStyle | Three different Styles (rounded,square,line) |
spacing | Custom line spacing between each box |
activeFieldColor | background color of the box when the text has been set (defaults to black) |
backgroundClr | A background color that for the boxes that will always be there, just like the first example |
font | Custom Font for the text |
textColor | Text Color for the text |
keyboardType | Change the type of keyboard (Defaults to numberPad) |
sagaya, [email protected]
PinView is available under the MIT license. See the LICENSE file for more info.