A UITextField with fully customizable formatter.
import MaskedUITextField
Use the MaskedFormatter framework in order to create a mask:
let mask = "##/$$-@@"
let rules = [
MaskedFormatter.Rule(maskCharacter: "#", validation: { $0.isNumber }),
MaskedFormatter.Rule(maskCharacter: "$", validation: { $0.isLetter }),
MaskedFormatter.Rule(maskCharacter: "@", validation: { (Int(String($0)) ?? 0) >= 5 })
]
let maskedFormatter = MaskedFormatter(mask: mask, rules: rules)
let textField = MaskedUITextField(formatter: maskedFormatter)
Alternatively:
let textField = MaskedUITextField()
textField.formatter = maskedFormatter