This commit is contained in:
DDIsFriend
2023-08-18 17:28:57 +08:00
commit f0e8a1709d
4282 changed files with 192396 additions and 0 deletions
@@ -0,0 +1,16 @@
//
// DDBaseTextField.h
// DDBasicControlsKit_Private
// Created by DDIsFriend on 2023/2/21.
#import <UIKit/UIKit.h>
#import <DDCategoryKit_Private/UITextField+DDCategory.h>
NS_ASSUME_NONNULL_BEGIN
@interface DDBaseTextField : UITextField
@property (nonatomic, assign)NSInteger textLimitCount;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,25 @@
//
// DDBaseTextField.m
// DDBasicControlsKit_Private
// Created by DDIsFriend on 2023/2/21.
#import "DDBaseTextField.h"
@implementation DDBaseTextField
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
self.textLimitCount = UINTMAX_MAX;
[self addTarget:self action:@selector(limitTextCount:) forControlEvents:UIControlEventEditingChanged];
}
return self;
}
- (void)limitTextCount:(UITextField *)textField{
if (textField.text.length >= self.textLimitCount) {
textField.text = [textField.text substringToIndex:self.textLimitCount];
}
}
@end