Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Last active December 30, 2020 16:54
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 sturdysturge/1ff5cbd27f863a8d4c075ffa5cce33b5 to your computer and use it in GitHub Desktop.
Save sturdysturge/1ff5cbd27f863a8d4c075ffa5cce33b5 to your computer and use it in GitHub Desktop.
UITextField Extensions First Responder
import UIKit
extension UITextField {
convenience init(coordinator: CustomTextField.Coordinator) {
self.init(frame: .zero)
self.delegate = coordinator
}
func setFirstResponder(_ isResponder: Bool) {
DispatchQueue.main.async {
if isResponder {
self.becomeFirstResponder()
} else {
self.resignFirstResponder()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment