Created
December 28, 2015 15:13
-
-
Save jplazcano87/8b5d3bc89c3578e45c3e to your computer and use it in GitHub Desktop.
Add Done Button to Numeric pad iOS (Swift)
extension UITextField {
func addDoneButtonOnKeyBoardWithControl() {
let keyboardToolbar = UIToolbar(frame: CGRect(0, 0, UIScreen.main.bounds.width, 44))
keyboardToolbar.sizeToFit()
keyboardToolbar.barStyle = .default
let flexBarButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let doneBarButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(self.endEditing(_:)))
keyboardToolbar.items = [flexBarButton, doneBarButton]
self.inputAccessoryView = keyboardToolbar
}
}
Then just call this on your textfield.
I am unsure what you mean by call this on your textfield?
thanks! It's useful
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gracias señor