ios - UITextField with a text length counter -
well title says mostly:
is there ready go uitextfield
component out there can take number (maximum text length) in label? cool if number can displayed.
is there component out there?
what have:
- limit input custom text length
- number of left character gets displayed inside textfield
- paste prevention
i created this uitextfieldlimit subclass:
- multiple textfields supported
- set text length limit
- paste prevention
- displays label of left characters inside textfield, hidden when stop editing.
- delegate
- shake animation when no characters left.
grab uitextfieldlimit.h
, uitextfieldlimit.m
github repository:
https://github.com/jonathangurebo/uitextfieldlimit
and begin test!
mark storyboard-created uitextfield , link subclass using identity inspector:
then can link iboutlet , set limit(default 10).
your viewcontroller.h file should contain: (if wan't modify setting, limit)
#import "uitextfieldlimit.h" /.../ @property (weak, nonatomic) iboutlet uitextfieldlimit *textfieldlimit; // <--your iboutlet
your viewcontroller.m file should @synthesize textfieldlimit
.
set text length limit in viewcontroller.m file:
- (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. [textfieldlimit setlimit:25];// <-- , won't able put more 25 characters in textfield. }
hope class helps you. luck!
Comments
Post a Comment