macOS, iOS

textFieldDelegate로 리턴버튼이나 textField 바깥 영역 눌렀을 때 keyboard dismiss

SweetDev 2019. 11. 22. 18:53

//This is for the keyboard to GO AWAYY !! when user clicks anywhere on the view

 

 

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {

self.view.endEditing(true)

}

 

 

//This is for the keyboard to GO AWAYY !! when user clicks "Return" key on the keyboard

func textFieldShouldReturn(textField: UITextField) -> Bool {

textField.resignFirstResponder()

return true

}