I have made a custom view and is hidden by default. By pressing a button I am unhiding it. Now I want to again hide it by adding outside the custom view. I have used touchesbegan with event but that is not serving the purpose. This is the function.
override func touchesBegan(touches: Set, withEvent event: UIEvent?) {
let touch = UITouch()
if touch.view?.tag == 1 { // 1 is the tag value for custom view
self.view1.hidden = false // view1 is the outlet for custom view
}
else{
self.view1.hidden = true
}
}