Skip to content

Instantly share code, notes, and snippets.

@maysamsh
Created August 6, 2020 14:20
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 maysamsh/b3ae0f04612c8e08579508428320229e to your computer and use it in GitHub Desktop.
Save maysamsh/b3ae0f04612c8e08579508428320229e to your computer and use it in GitHub Desktop.
//
// UIViewController+Ext.swift
//
//
// Created by Maysam Shahsavari on 2020-08-06.
//
import Foundation
import UIKit
extension UIViewController {
func shouldResignKeyboardOnTap() {
let tap = UITapGestureRecognizer(target: self, action: #selector(endEditingFields))
self.view.addGestureRecognizer(tap)
}
@objc func endEditingFields (){
view.endEditing(true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment