/SwiftMaskText

Another Swift plugin that allows add mask to UITextField

Primary LanguageSwiftMIT LicenseMIT

Release GitHub issues GitHub license GitHub stars GitHub forks

Carthage Compatible Pod Compatible

SwiftMaskText

Another Swift plugin that allow add mask to UITextField

App Preview

Why to use it?

  • Because it's simples and fast
  • Configuration is through Settings Panel
  • Works with Swift 4.2

Mask Configuration

Mask Symbols

Characters Format
N Number only [0-9]
C Characters [A-Z] (Always upper case)
c Characters [a-z] (Always lower case)
X Characters [a-Z]
U Characters + Numbers [A-Z] + [0-9] (Always upper case)
u Characters + Numbers [a-z] + [0-9] (Always lower case)
% Characters + Numbers [a-Z] + [0-9]
* Any character (Including special ones)

Some examples

Internacional examples

Field Mask
SSN NNN-NN-NNNN
Telephone +NN (NNN) NNN-NNNN
Credit Card NNNN-NNNN-NNNN-NNNN

Brazilian examples

Field Mask
Telephone +NN (0NN) NNNNN-NNNN
CPF NNN.NNN.NNN-NN
RG NN.NNN.NNN-%
CEP NNNNN-NNN

How to use it?

Using Carthage

github "moraisandre/SwiftMaskText"

Using CocoaPods

pod 'SwiftMaskText'

Copy files to your project

  1. Add the SwiftMaskField folder to your project, it contains 2 files. Be sure that 'Copy items if needed' is checked. Copy Items If Needed

  2. In your ViewController add an UITextField object. In 'Settings Panel' -> 'Identity inspector' set Class to 'SwiftMaskField' Custom Class

  3. Now go into 'Settings Panel' -> 'Attributes inspector' and set the Mask that you want it to Swift Mask Field

  4. Done!

More info

Author

André Morais

Website: moraisandre.com/swiftmasktext

E-mail: morais@andremorais.com.br

License

Under the MIT license.