Tuesday 18 April 2017

How to hide keyboard in swift on pressing return key or touch any where in View




class ViewController: UIViewController,UITextFieldDelegate{

 @IBOutlet weak var chatting_Textfield: UITextField!
  
    override func viewDidLoad() {
        super.viewDidLoad()
{
self.chatting_Textfield.delegateself
}


   override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.view.endEditing(true)
    }
    
    func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
        chatting_Textfield.resignFirstResponder()
        return (true)
    }

}

No comments:

Post a Comment

Remove bottom line in navigation bar

navigationController ?. navigationBar . setBackgroundImage ( UIImage (), for: . any , barMetrics: . default )          navigat...