STLimitTextField is a textfield that can limit the length of the text. You can limit the length of the text or the length of the character.
- iOS 8.0 or later (For iOS 8.0 before, maybe it can work, but I have not tested.)
- ARC
STLimitTextField is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'STLimitTextField'
In the source files where you need to use the library, import the header file:
#import <STLimitTextField/STLimitTextField.h>
STLimitTextField is a subclass of UITextFiled. You can initialize it like UITextField, of course you can also use storyboard:
STLimitTextField *textFiled = [[STLimitTextField alloc] init];
STLimitTextFiled has two ways to limit the length of the text. You can use STLimitLength
to limit the length of the text, or use STLimitChar
to limit the length of the text characters:
textFiled.limitType = STLimitLength;
STLimitTextFiled can set the limit length with code or storyboard:
textFiled.limit = 5;
Suta, [email protected]