It is a subclass of UITextfield to Provide the mask and message error label.
- iOS 8.0+ / Mac OS X 10.9+ / Apple TV 11
- Xcode 9.0+, Swift 4
- Add a pod entry for MaskTextField to your Podfile
pod 'RNMaskTextField'
- Install the pod(s) by running
pod install
.
- Drag MaskTextField.swift and FormTextField.swift to your project
- Show a message of error in your TextField
self.textField.showAccessoryLabel(withText: "Message Error")
- Set a mask to your TextField
self.textField.textMask = "###.###"
/// Set the textField delegate and call the function shouldChangeCharacters(...)
extension ObjectObserver: UITextFieldDelegate {
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
return (textField as! MaskTextField).shouldChangeCharacters(in: range, replacementString: string)
}
}
- Text Mask
textMask: String
*Default Char Mask
defaultCharMask: String = "#"
- Draw Text with edge insets. Default is .zero.
textEdgeInsets: UIEdgeInsets
*Accessory Font
accessoryFont: UIFont
*Accessory Text Color. Default is .red
accessoryTextColor: UIColor
- Shake AccessoryLabel when Showing text. Default is true
shakeAccessoryLabel : Bool