iOS灰色按钮输入变亮

didLoad里面   先设置灰色  不让点击

  [_enterPayBtn setBackgroundColor:[UIColor lightGrayColor]];

    _enterPayBtn.layer.cornerRadius = 8;

    _enterPayBtn.layer.masksToBounds = YES;

    _enterPayBtn.userInteractionEnabled=NO;

输入的时候 自己变亮,这里不用判断text的长度,第一个字符是不作为计算length的

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{

    

        [_enterPayBtn setBackgroundColor:kDefault_System_Color];

        _enterPayBtn.userInteractionEnabled=YES;

   

    return YES;

}

清除又变灰

- (BOOL)textFieldShouldClear:(UITextField *)textField{

    [_enterPayBtn setBackgroundColor:[UIColor lightGrayColor]];

    _enterPayBtn.userInteractionEnabled=NO;

    return YES;

}

你可能感兴趣的:(苹果)