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.
You could create another transparent button or, your base view (assuming it's a single view below the button) can then address what you're trying to do. First, you would need to make it tappable. Then you want to handle the logic for what happens when tapped, or untapped.