动态实时监听文本框中内容的变化

@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];

 }

 

posted @ 2015-12-08 18:50  依然哎  阅读(530)  评论(0编辑  收藏  举报