Another Swift plugin that allow add mask to UITextField
- Because it's simples and fast
- Configuration is through Settings Panel
- Works with Swift 4.2
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) |
Field | Mask |
---|---|
SSN | NNN-NN-NNNN |
Telephone | +NN (NNN) NNN-NNNN |
Credit Card | NNNN-NNNN-NNNN-NNNN |
Field | Mask |
---|---|
Telephone | +NN (0NN) NNNNN-NNNN |
CPF | NNN.NNN.NNN-NN |
RG | NN.NNN.NNN-% |
CEP | NNNNN-NNN |
github "moraisandre/SwiftMaskText"
pod 'SwiftMaskText'
-
Add the SwiftMaskField folder to your project, it contains 2 files. Be sure that 'Copy items if needed' is checked.
-
In your ViewController add an UITextField object. In 'Settings Panel' -> 'Identity inspector' set Class to 'SwiftMaskField'
-
Now go into 'Settings Panel' -> 'Attributes inspector' and set the Mask that you want it to
-
Done!
André Morais
Website: moraisandre.com/swiftmasktext
E-mail: morais@andremorais.com.br
Under the MIT license.