An easy to use UITextField subclass that adds a visibility toggle and an optional validation checkmark
Created by @lookatpete (product), @pklada (design), and @miketsprague (code)
pod 'HideShowPasswordTextField', :git => 'https://github.com/Guidebook/HideShowPasswordTextField'
Just add the files in HideShowPasswordTextField/ to your project.
- Create a UITextFieldin your xib, and change the class name toHideShowPasswordTextField. Or, create it programatically.
- Set secureTextEntrytotrue, if you want the password to hide by default.
- [Recommended] Change the border style to None, and add a height constraint of 44 or larger. The assets in this project are optimized for 44px, although larger is fine too. Smaller sizes might have clipping issues on the icons.
- Implement- UITextFieldDelegateand forward- textField shouldChangeCharactersInRangeand- textFieldDidEndEditingto your password text field (see the example). We have to do this to get the behavior to work right--apple's API doesn't play very nice switching between- secureTextEntrystates.- This step is no longer necessary.
 
- [Optional] Implement HideShowPasswordTextFieldDelegateto show the validation checkbox.
- Customize the textField to your liking (the tint too!)!
