Hide keyboard and other when click outside in swift (ios)

@IBOutlet var myTextFiled : UITextFiled!

override func viewDidLoad()
    {
        let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard (_:)))
        tapGesture.cancelsTouchesInView =                                                                               false
             self.view.addGestureRecognizer                                                                 (tapGesture)
}

    @objc func dismissKeyboard (_ sender: UITapGestureRecognizer) {
        myTextFiled.resignFirstResponder()
    }

Comments

Popular posts from this blog

Windows Keys

Important extensions while create a new App in swift

S.O.L.I.D. Principles with Example (Swift & Dart)