????????3??????????Ч??

???????????????棺
????1.У????????????
????- (BOOL)isValidateMobile:(NSString *)mobile
????{
????NSString *phoneRegex = @"^[1][3??4??5??8??7][0-9]{9}$";
????NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@"?? phoneRegex];
????return [phoneTest evaluateWithObject:mobile];
????}
????2.У???????????????????????????
????3.??????????????????????
????4.????????????????????????????????????????????????
??????????????
????????????????????xib?????????棬??????KVC
????[_phone addTarget:self action:@selector(changePhone) forControlEvents:UIControlEventEditingChanged];
????[_password addTarget:self action:@selector(changeAction) forControlEvents:UIControlEventEditingChanged];
????[_email addTarget:self action:@selector(changeAction) forControlEvents:UIControlEventEditingChanged];
????[_loginButton setEnabled:NO];
????[_loginButton addTarget:self action:@selector(loginButtonAction) forControlEvents:UIControlEventTouchUpInside];
????????????
????????????????????
- (void)changePhone {
if (_phone.text.length >= 11) {
if ([self isValidateMobile:_phone.text]) {
_phone.textColor = [UIColor blackColor];
[_password becomeFirstResponder];
} else {
_phone.textColor = [UIColor redColor];
}
} else {
_phone.textColor = [UIColor blackColor];
}
}
???????????textfield??????????
- (void)changeAction {
if ((_password.text.length >= 1 && _phone.text.length >=     11 && _email.text.length >= 1) && [self isValidateMobile:_phone.text]) {
// ????????????? enable ???????userInteractionEnabled  ???????дsetEnabled????????????????????Ч??
[_loginButton setEnabled:YES];
} else {
[_loginButton setEnabled:NO];
}
}
?????????????????????????????????????????????????????????????????????????????????????д???UIButton????????????????????????????Ч??
// .h
#import <UIKit/UIKit.h>
@interface UIButton (enable)
@end
// .m
#import "UIButton+enable.h"
@implementation UIButton (enable)
- (void)setEnabled:(BOOL)enabled {
[super setEnabled:enabled];
if (enabled) {
self.alpha = 1.0;
} else {
self.alpha = 0.5;
}
}
@end
??????????????????????????????д??????????????????