Hide keyboard in swift

Use following delegate method of UITextField for hide keyboard


func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        
        textField.resignFirstResponder()
        return true
}