@property (strong, nonatomic) UITextField *iPhoneText;
@property (strong, nonatomic) UITextField *passwordText;
@property (strong, nonatomic) UIButton *passwordBtn;
viewdidLoad 中设置文本框的监听变化的方法
[self.iPhoneText addTarget:self action:@selector(textChange) forControlEvents: UIControlEventEditingChanged];
[self.passwordText addTarget:self action:@selector(textChange) forControlEvents:UIControlEventEditingChanged];
[self textChange];
///根据判断 text1与 text2是否有值
-(void)textChange{
self.loginBtn.enabled = self.iPhoneText.text.length && self.passwordText.text.length;
[self.loginBtn setBackgroundColor:LoginButtonColor];
}
时间: 2024-10-08 00:22:51