Last active
July 14, 2017 09:24
-
-
Save PaulRBerg/abac04e406815408ddd38921d9cd2caf to your computer and use it in GitHub Desktop.
AdPacer - APLoginTextFieldController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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