ZASTextFieldFormat Development Background
During the development process, every time I write UITextField, I can’t help but feel unhappy, because I have to consider various input restrictions and implement some troublesome and cumbersome things such as agents and notifications, so I wrote thisZASTextFieldFormat (Local download) Simple wheels, use them temporarily, and wait for the later stage to be gradually optimized and improved.
Introduction to ZASTextFieldFormat
One line of code, set the input format limits of UITextField, such as mobile phone number, ID number, bank card number format, and number of input character types, etc.;
Interface description
/** * ZASTextFieldFormatDelegate proxy * */ @property (nonatomic, assign) id<ZASTextFieldFormatDelegate> zasDelegate; /** * Set the floating point type, only two decimal places are allowed to enter floating point types (default=NO) * */ @property (nonatomic, assign) Boolean isFloat; /** * Set regular matching mode (if regular mode is set, other format restrictions are ignored) * */ @property (nonatomic, copy) NSString * pattern; /** * Set the entry to control the UITextFiled format (Note: This entry must be called) * format=nil or "" does not limit the format, charactersInString=nil or "" does not limit the characters, maxLimit=0 does not limit the number * * Example: Take mobile phone number as an example * @param format, eg: ### #### #### * @param charactersInString Support input characters, eg: 0123456789 * @param maxLimit Maximum input limit, eg: 11 * Result input: 159 1234 5678 */ - (void)textFieldWithFormat:(NSString *)format charactersInString:(NSString *)charactersInString maxLimit:(NSInteger)maxLimit;
Specific use
Make the original UITextField inherit from ZASTextFieldFormat, and then call how to interface;
[_tfPhone textFieldWithFormat:@"### #### ####" charactersInString:@"0123456789" maxLimit:11];
Reference Demo
Click here to get the demo(Local download)
Summarize
The above is the entire content of this article. I hope that the content of this article has a certain reference value for everyone's study or work. If you have any questions, you can leave a message to communicate. Thank you for your support.