Simple extension to add a reveal button to your boring UITextField
- iOS 8.0+
- Swift 3.0+
- Xcode 8.0+
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 1.1.0+ is required to build RevealTextField 1.0.3+.
To integrate RevealTextField into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'RevealTextField', '~> 1.0.3'
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate RevealTextField into your Xcode project using Carthage, specify it in your Cartfile
:
github "LeonardoCardoso/RevealTextField" ~> 1.0.3
If you prefer not to use either of the aforementioned dependency managers, you can integrate RevealTextField into your project manually.
You can use a RevealTextField
on any UITextField
by just calling the function revealable()
. Yes it's an extension, not a subclass:
let passwordTextField = UITextField()
passwordTextField.isSecureTextEntry = true
passwordTextField.revealable() // <<---
passwordTextField.revealable(secureImage: UIImage?, // <<--- isSecureTextEntry == true.
unsecureImage: UIImage?, // <<--- isSecureTextEntry == false.
tintColor: UIColor?, // <<--- image color, default is black.
dimension: CGFloat?) // <<--- image dimension, default is 30.
revealable()
transforms your boringUITextField
into a RevealingUITextField
.toggleReveal()
toggles the review automatically at any time. It applies to everyUITextField
.toggleImage(_ isSecure: Bool)
toggles revealing image at any time.
RevealTextField is released under the MIT license. See LICENSE for details.