How to dismiss UIAlertController when tap outside the UIAlertController?
If you are targeting devices having iOS > 9.3 and using Swift and preferredStyle is Alert you can use snippet as below: func showAlertBtnClicked(sender: UIButton) { let alert = UIAlertController(title: “This is title”, message: “This is message”, preferredStyle: .Alert) self.presentViewController(alert, animated: true, completion:{ alert.view.superview?.userInteractionEnabled = true alert.view.superview?.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.alertControllerBackgroundTapped))) }) } func alertControllerBackgroundTapped() { … Read more