I want to Hidden a Navigationbar and Toolbar when i Tap on a UIImageView and when the NavigationBar and Toolbar is hidden and a tap once again i want it back.
@IBOutlet var ToolBar: UIToolbar!
@IBOutlet var NavigationBar: UINavigationBar!
@IBOutlet var FullPhoto: UIImageView!
I have this tried but it doest´n works, when i take the view instead of FullPhoto it goes but the Navigationbar and Toolbar is hidden wenn i tap on the Navigationbar and Toolbar.I would to hidden it when i tap on the UIImageView.
let tapRecognizer = UITapGestureRecognizer(target: self, action: "tapImage")
FullPhoto.addGestureRecognizer(tapRecognizer)
Here wos the Code for Hidden the Navigationbar and Toolbar but i would when tap on it it´s hidden and tap once again it´s comes again.
func tapImage () {
NavigationBar.hidden = true
ToolBar.hidden = true
}
Thanks for Help.
You don´t even need to create outlets for your navBar
and tabBar
to achieve this. Create an outlet to your imageView
as you have done.
@IBOutlet var FullPhoto: UIImageView!
And then in your viewDidLoad
let tapRecognizer = UITapGestureRecognizer(target: self, action: "tapImage")
FullPhoto.addGestureRecognizer(tapRecognizer)
FullPhoto.userInteractionEnabled = true
And then create the tap method and check for the navigationController
and the tabBarController
.
func tapImage(){
if navigationController?.navigationBar.hidden == false && tabBarController?.tabBar.hidden == false{
navigationController?.navigationBar.hidden = true
tabBarController?.tabBar.hidden = true
}
else{
navigationController?.navigationBar.hidden = false
tabBarController?.tabBar.hidden = false
}
}