前面写一了篇,UITextField Category来限制输入的字数,是有个Bug的,要输入中文时会crash。如今改动 了下。代码例如以下

.h文件

#import <UIKit/UIKit.h>

@interface UITextField (LimitLength)
/**
 *  使用时仅仅要调用此方法,加上一个长度(int)。就能够实现了字数限制,汉字不能够
 *
 *  @param length
 */
- (void)limitTextLength:(int)length;
/**
 *  uitextField 抖动效果
 */
- (void)shake;
@end

.m文件


參考:http://www.keepwhy.com/index.php/archives/296

http://blog.sina.com.cn/s/blog_60f977e70101g4gj.html

http://www.2cto.com/kf/201406/312073.html


相关文章: