Skip to content

Instantly share code, notes, and snippets.

@rickyngan
Last active May 25, 2018 19:25
Show Gist options
  • Save rickyngan/cf45148734d6ddc8800a to your computer and use it in GitHub Desktop.
Save rickyngan/cf45148734d6ddc8800a to your computer and use it in GitHub Desktop.
LoginButton enable when both username and password textfields are filled.
loginUserNameTextField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged)
loginUserPasswordTextField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged)
@objc func textFieldDidChange(_ textField: UITextField) {
loginButton.enabled = loginUserNameTextField.text.length && loginUserPasswordTextField.text.length
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment