Skip to content

souzainf3/RNMaskTextField

Repository files navigation

RNMaskTextField

It is a subclass of UITextfield to Provide the mask and message error label.

Requirements

  • iOS 8.0+ / Mac OS X 10.9+ / Apple TV 11
  • Xcode 9.0+, Swift 4

Adding RNMaskTextField to your project

Cocoapods

  1. Add a pod entry for MaskTextField to your Podfile pod 'RNMaskTextField'
  2. Install the pod(s) by running pod install.

Manually

  1. Drag MaskTextField.swift and FormTextField.swift to your project

Using RNMaskTextField

  • 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)
}
}

MaskTextField Properties

  • Text Mask
textMask: String

*Default Char Mask

defaultCharMask: String = "#"

FormTextField Properties

  • 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

About

It is a subclass of UITextfield to Provide the mask and message error label.

Resources

License

Stars

Watchers

Forks

Packages

No packages published