How to Dismiss the Keyboard in iOS

This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io

First, drag the ‘Tap Gesture Recognizer’ from Object Library onto Background. Then control-drag from ‘Tap Gesture Recognizer’ to ViewController.swift to add the dismissKeyboard() @IBAction. And last, call the resignFirstResponder() method from within the dismissKeyboard function to then dismiss the keyboard.

@IBAction func dismissKeyboard(_ sender: UITapGestureRecognizer) {
mySuperSweetTextField.resignFirstResponder()
}
 

topherPedersen