PasswordTextField
A custom TextField with a switchable icon which shows or hides the password and enforce good password policies
Install / Use
/learn @PiXeL16/PasswordTextFieldREADME

PasswordTextField
A custom TextField with a switchable icon which shows or hides the password and enforces good password policies, written in Swift.

:star: Features
- Custom toggle icon in IB or programmatically.
- Custom icon color in IB or programmatically.
- Custom password validation rules.
- Custom password validation error message.
- Control when to show the icon, while editing, always or never.
:octocat: Installation
Swift Package Manager (SPM)
- In Xcode 11+ select File > Packages > Add Package Dependency....
- Enter this project's URL: https://github.com/PiXeL16/PasswordTextField.git
CocoaPods
You can use CocoaPods to install PasswordTextField by adding it to your Podfile:
platform :ios, '12.0'
use_frameworks!
pod 'PasswordTextField'
To get the full benefits import PasswordTextField wherever you import UIKit
import UIKit
import PasswordTextField
Carthage
Create a Cartfile that lists the framework and run carthage bootstrap. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/PasswordTextField.framework to an iOS project.
github "PiXeL16/PasswordTextField"
Manually
- Download and drop
/PasswordTextFieldfolder in your project. - Congratulations!
:metal: Usage
- Open a storyboard or Xib file.
- Drag and drop a
UITextFieldto a ViewController. - In Identity Inspector, replace the class from
UITextFieldtoPasswordTextFieldand the module toPasswordTextField. - Configure your properties in the Attribute Inspector.

Properties
| Property name | Data type | Remark |
| ------------- |:-------------:| ----- |
| Show Toggle Button While | String | Possible values are editing(default), always, never |
| Image Tint Color | UIColor | The color off the Toggle image, the functionality use UIImageRenderingMode.AlwaysTemplate to change the default or custom image color|
|Custom Show Secure Text Image| UIImage| Your custom image to show the secure text|
|Custom Hide Secure Text Image| UIImage| Your custom image to hide the secure text|
Validation
PasswordTextField also provides functionality to enforce good password policies.
It will currently validate that the password format is at least 8 characters long and contain one uppercase letter and one number.
import PasswordTextField
if passwordTextField.isInvalid(){
print(passwordTextField.errorMessage)
}
You can also provide your custom password validation format (with Regex) and error message:
import PasswordTextField
let validationRule = RegexRule(regex:"^[A-Z ]+$", errorMessage: "Password must contain only uppercase letters")
passwordTextField.validationRule = validationRule
if passwordTextField.isInvalid(){
print(passwordTextField.errorMessage)
}
TODO
- Show indication when password is strong or weak in TextField
- Animation when toggling Button
:alien: Author
Chris Jimenez - http://code.chrisjimenez.net, @chrisjimeneznat
:beer: Donate
If you want to buy me a beer, you can donate to my coin addresses below:
BTC
1BeGBew4CBdLgUSmvoyiU1LrM99GpkXgkj
ETH
0xa59a3793E3Cb5f3B1AdE6887783D225EDf67192d
LTC
Ld6FB3Tqjf6B8iz9Gn9sMr7BnowAjSUXaV
License
PasswordTextField is released under the MIT license. See LICENSE for details.
Related Skills
node-connect
339.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.8kCommit, push, and open a PR