Question : how to dismiss a view when touch up inside swift
Answered by : homeless-hare-yndri6wki812
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { let touch = touches.first if touch?.view != self.yourView { self.dismiss(animated: true, completion: nil) } }
Source : https://stackoverflow.com/questions/42385450/ios-how-to-hide-a-view-by-touching-anywhere-outside-of-it | Last Update : Mon, 18 Jan 21