// // PBInputCodeTableViewCell.m // IphoneBIMe // // Created by zjf on 2020/7/16. // Copyright © 2020 ProBIM. All rights reserved. // #import "PBInputCodeTableViewCell.h" @interface PBInputCodeTableViewCell() @property (nonatomic, weak) UIView *codeBgV; @property (nonatomic, weak) UIImageView *logoImageV; @property (nonatomic, weak) UITextField *codeTF; @property (nonatomic, weak) UIView *linV; @end @implementation PBInputCodeTableViewCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self setupUI]; } return self; } - (void)setupUI { self.contentView.backgroundColor = PromptColor; UIView *codeBgV = [[UIView alloc] init]; codeBgV.backgroundColor = [UIColor whiteColor]; [self.contentView addSubview:codeBgV]; [codeBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); make.bottom.equalTo(self.contentView).offset(-20); }]; [codeBgV circleViewWithRadius:6]; UIImageView *logoImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo_unknown"]]; [self.contentView addSubview:logoImageV]; [logoImageV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(codeBgV).offset(26); make.centerX.equalTo(codeBgV); make.size.mas_equalTo(CGSizeMake(36, 36)); }]; UIView *linV = [[UIView alloc] init]; linV.backgroundColor = PBColor(233, 235, 237); [self.contentView addSubview:linV]; [linV mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(codeBgV).offset(-31); make.left.equalTo(codeBgV).offset(67); make.right.equalTo(codeBgV).offset(-67); make.height.equalTo(@1); }]; UITextField *codeTF = [[UITextField alloc] init]; codeTF.placeholder = @"输入自有企业服务编码"; codeTF.textAlignment= NSTextAlignmentCenter; codeTF.textColor = PBColor(40, 58, 79); codeTF.font = [UIFont fontWithName:Coarse size:16.0]; codeTF.keyboardType = UIKeyboardTypeNumbersAndPunctuation; codeTF.clearButtonMode = UITextFieldViewModeAlways; codeTF.delegate = self; codeTF.returnKeyType = UIReturnKeyDone; [self.contentView addSubview:codeTF]; [codeTF mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(linV).offset(-1); make.left.right.equalTo(linV); make.height.equalTo(@34); }]; self.codeBgV = codeBgV; self.logoImageV = logoImageV; self.codeTF = codeTF; self.linV = linV; } #pragma mark - UITextFieldDelegate - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { self.logoImageV.image = [UIImage imageNamed:@"logo_unknown_nor"]; if ([[_dict valueForKey:@"err"] isEqualToString:@"err"]) { [_dict setValue:@"" forKey:@"err"]; self.codeBgV.backgroundColor = [UIColor whiteColor]; self.codeTF.textColor = PBColor(40, 58, 79); if (self.SolveErr) { self.SolveErr(); } } return YES; } - (BOOL)textFieldShouldEndEditing:(UITextField *)textField { self.logoImageV.image = [UIImage imageNamed:@"logo_unknown"]; return YES; } - (BOOL)textFieldShouldReturn:(UITextField *)textField { [self.codeTF resignFirstResponder]; if (self.GetEnterpriseBlock) { self.GetEnterpriseBlock(textField.text); } return YES; } - (void)setDict:(NSMutableDictionary *)dict { _dict = dict; if ([[dict valueForKey:@"err"] isEqualToString:@"err"]) { self.codeBgV.backgroundColor = PBColor(244, 21, 21); self.logoImageV.image = [UIImage imageNamed:@"logo_unknown_erro"]; self.codeTF.textColor = [UIColor whiteColor]; self.codeTF.text = [dict valueForKey:@"code"]; }else { self.codeBgV.backgroundColor = [UIColor whiteColor]; self.logoImageV.image = [UIImage imageNamed:@"logo_unknown"]; self.codeTF.text = [dict valueForKey:@"code"];; self.codeTF.textColor = PBColor(40, 58, 79); } } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end