Skip to content

Instantly share code, notes, and snippets.

@asisadh
Created March 17, 2019 11:41
Show Gist options
  • Save asisadh/3c605ee38fe17970542b6422d16de8ec to your computer and use it in GitHub Desktop.
Save asisadh/3c605ee38fe17970542b6422d16de8ec to your computer and use it in GitHub Desktop.
ViewController
class ViewController: UIViewController {
@IBOutlet weak var txtFieldDemo: UITextField! {
didSet{
txtFieldDemo.delegate = self
txtFieldDemo.addTarget(self, action: #selector(textFieldDidChange(textField:)), for: .editingChanged)
}
}
}
extension ViewController: UITextFieldDelegate{
func textFieldDidBeginEditing(_ textField: UITextField) {
textField.underlined()
}
func textFieldDidEndEditing(_ textField: UITextField) {
textField.removeUnderline()
}
@objc func textFieldDidChange(textField: UITextField){
textField.hideUnderline()
textField.underlined()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment