initial
This commit is contained in:
Pods/DDBasicControlsKit_Private/DDBasicControlsKit_Private/Classes/DDBaseTextField/DDBaseTextField.h
Generated
+16
@@ -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
|
||||
Pods/DDBasicControlsKit_Private/DDBasicControlsKit_Private/Classes/DDBaseTextField/DDBaseTextField.m
Generated
+25
@@ -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
|
||||
Reference in New Issue
Block a user