Skip to content

Instantly share code, notes, and snippets.

@PaulRBerg
Last active July 14, 2017 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulRBerg/abac04e406815408ddd38921d9cd2caf to your computer and use it in GitHub Desktop.
Save PaulRBerg/abac04e406815408ddd38921d9cd2caf to your computer and use it in GitHub Desktop.
AdPacer - APLoginTextFieldController
import UIKit
extension APLoginViewController: UITextFieldDelegate {
/**
* Append the fully configured text fields to the view controller.
*/
func appendTextField() {
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 25, height: 25))
imageView.image = UIImage(named: "ic_question_mark")
imageView.isUserInteractionEnabled = true
imageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(APLoginViewController.didTapForgotPasswordButton)))
passwordTextField.rightViewMode = .always
passwordTextField.rightView = imageView
}
/**
* The text field delegate.
*/
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if textField == emailTextField {
passwordTextField.becomeFirstResponder()
}
if textField == passwordTextField {
didTapSignInButton(textField)
}
return true
}
/**
* Called when the background was tapped.
*/
@IBAction func didTapBackground(_ sender: Any) {
view.endEditing(true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment