PasswordTextField
  • October 21, 2023

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

⭐  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


CocoaPods

You can use CocoaPods to install PasswordTextField by adding it to your Podfile:

platform :ios, ‘8.0’
use_frameworks!
pod ‘PasswordTextField’

To get the full benefits import PasswordTextField wherever you import UIKit

import UIKit
import PasswordTextField

Cartahge

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”

Swift Package Manager

NOTEThese instructions are intended for usage on Xcode 11 and higher. Xcode 11 is the first version of Xcode that integrates Swift Package Manager and makes it way easier to use than it was at the command line. If you are using older versions of Xcode, we recommend using CocoaPods.

  1. Go to File > Swift Packages > Add Package Dependency…
  2. Paste the URL to the PasswordTextField repo on GitHub (https://github.com/PiXeL16/PasswordTextField.git) into the search bar, then hit the Next button:
  3. Select the latest version and then hit next (Xcode will automatically suggest the current version Up to Next Major).
  4. Select the PasswordTextField library and then hit finish.
  5. You’re done!

 

Manual
  1. Download and drop /PasswordTextField folder in your project.
  2. Congratulations!

🤘 Usage


  1. Open a storyboard or Xib file.
  2. Drag and drop a UITextField to a ViewController.
  3. In Identity Inspector, replace the class from UITextField to PasswordTextField and the module to PasswordTextField.
  4. Configure your properties in the Attribute Inspector.

Properties


Property name Data type Remark
Show Toggle Button While String Possible values are editing(default), alwaysnever
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)
}

GitHub


View Github

#animation #awesemetextfield #carthage #cocoapods #currencytextfield #customtextfield #customwidgets #facetedsearch #geosearch #growingtextview #instantsearch #interfacebuilder #ios #ioslibrary #iosswift #opensource #password #passwordtextfield #placeholder #placeholdertextview #realmswift #search #searchengine #searchinterface #searchsynonyms #styledtext #swift #swiftframework #swiftlibrary #swiftpackagemanager #swiftui #swiftuicomponents #textexpansion #textfield #texture #textview #tjtextfield #ui #uikit #uitextfield #uitextfieldnavigation #uitextview #uitextviewalgolia #widgets
YOU MIGHT ALSO LIKE...
CameraBackground

Features Both front and back camera supported. Flash modes: auto, on, off. Countdown timer. Tap to focus. Pinch to zoom. Usage  

DKCamera

Description A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so ...

HorizonSDK-iOS

Horizon SDK is a state of the art real-time video recording / photo shooting iOS library. Some of the features ...

LLSimpleCamera

LLSimpleCamera: A simple customizable camera - video recorder control LLSimpleCamera is a library for creating a customized camera - video ...

RSBarcodes_Swift

RSBarcodes allows you to read 1D and 2D barcodes using the metadata scanning capabilities introduced with iOS 7 and generate ...