I'm new to IOS programming, I'm displaying a view when a button is clicked, using the following code inside the button method.
@IBAction func moreButton(_ sender: Any)
{
self.helpView.isHidden = false
}
initially, the self.helpView.isHidden
is set to true in viewDidLoad
method to hide the view. Now, how can i dismiss this view by touching anywhere outside the view. From the research, i found that, it can be done by creating a transparent button that fits the whole viewController. So then by clicking on the button, we can make the view to dismiss. Can anyone give me the code in swift 3 to create such button.
Or, if there is any other better way to hide a view, it is welcomed.
I'm using Xcode 8.2, swift 3.0
Thanks in advance.
touchesBegan
and check if the touch view is the view or not/ or compare the touch position to hide it