1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- //
- // KDPScreenBtnView.m
- // KuDianProject
- //
- // Created by admin on 2019/7/8.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPScreenBtnView.h"
- @interface KDPScreenBtnView ()<UITextFieldDelegate>
- @property (nonatomic, strong) UITextField *textField;
- @end
- @implementation KDPScreenBtnView
- - (instancetype)initWithFrame:(CGRect)frame{
- if (self = [super initWithFrame:frame]) {
- [self setSubViews];
- }
- return self;
- }
- - (void)setSubViews{
- self.backgroundColor = [UIColor colorWithRGB:0xf4f4f4];
- self.textField = [[UITextField alloc] init];
- self.textField.delegate = self;
- self.textField.keyboardType = UIKeyboardTypeNumberPad;
- self.textField.textAlignment = NSTextAlignmentCenter;
- self.textField.font = FONT_SYS(14);
- [self.textField addTarget:self action:@selector(textFieldChanged:) forControlEvents:UIControlEventEditingChanged];
- [self addSubview:self.textField];
- [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
- make.size.equalTo(CGSizeMake(self.width, 30));
- make.centerX.equalTo(self);
- make.centerY.equalTo(self);
- }];
- }
- - (void)setTextColor:(UIColor *)textColor{
- _textColor = textColor;
- self.textField.textColor = textColor;
- }
- - (void)setIsEditing:(BOOL)isEditing{
- _isEditing = isEditing;
- self.textField.enabled = isEditing;
- }
- - (void)setPlaceHolderText:(NSString *)placeHolderText{
- _placeHolderText = placeHolderText;
- self.textField.placeholder = placeHolderText;
- }
- - (void)setText:(NSString *)text{
- self.textField.text = text;
- }
- - (NSString *)text{
- if (!self.textField.text.length) {
- return @"";
- }
- return self.textField.text;
- }
- - (void)textFieldChanged:(UITextField *)textfield{
- if ([self.delegate respondsToSelector:@selector(textFieldValueChanged:)]) {
- [self.delegate textFieldValueChanged:textfield];
- }
- }
- - (void)textFieldDidEndEditing:(UITextField *)textField{
- if ([self.delegate respondsToSelector:@selector(textFieldDidEndEditing:)]) {
- [self.delegate textFieldDidEndEditing:textField];
- }
- }
- - (void)textFieldDidBeginEditing:(UITextField *)textField{
- if ([self.delegate respondsToSelector:@selector(textFieldDidBeginEditing:)]) {
- [self.delegate textFieldDidBeginEditing:textField];
- }
- }
- @end
|