只有文本框输入自定长度的字符时,按钮才会被点击
实现这种效果的是textfield 的shouldChangeCharactersInRange回调方法
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSUInteger length = textField.text.length - range.length + string.length;
if (length > 0) {
btn_login.enabled = YES;
btn_login.alpha = UI_ENABLED_YES_ALPHA;
} else {
btn_login.enabled = NO;
btn_login.alpha = UI_ENABLED_NO_ALPHA;
}
return YES;
}