An iOS app that imitates Apple's passcode entry to showcase the a single digit UITextField custom class; SecureCodeTextField
.
- Only allow a single digit per textfield
- Disables UITextField action menu commands to prevent copy/paste
- Cursor auto moves to previous/next textfield after a single character text entry
- Works with arbitrary amount of textfields on screen
- Copy and paste SecureCodeTextField.swift into your project
- Set the custom class of the
UITextField
s on your storyboard file toSecureCodeTextField
- Point the current
SecureCodeTextField
'spreviousTextField
andnextTextField
to the respective text fields. For example:let firstTF = SecureCodeTextField() let secondTF = SecureCodeTextField() let thirdTF = SecureCodeTextField() secondTF.previousTextField = firstTF secondTF.nextTextField = thirdTF
- Your textfields should now jump to previous/next textfields as desired!
Look into the ViewController.swift file and you should be able to understand in the scenario where we have 4 SecureCodeTextFields
s