Closed ElyDantas closed 7 years ago
By making tabController static... dah
public static var tabController:AZTabBarController!
@ElyDantas The AZTabBar doesn't include this kinda of feature out of the box, however I can provide a simple solution for you:
Create a custom protocol and specify the events you wish to trigger:
protocol MyCustomDelegate{
func requestTabVisability(show: Bool, animate: Bool)
}
Then conform your ViewController in which you have an instance member of AZTabBarController to that Custom Delegate:
extension ViewController: MyCustomDelegate{
func requestTabVisability(show: Bool, animate: Bool){
self.tabBar.setBar(hidden: !show, animated: animate)
}
}
Then in your child view controller, create an instance member of that protocol:
class MyChildViewController: UIViewController{
...
var delegate: MyCustomDelegate?
...
}
Now when you are about to add the child view controller to the tab bar simply do this:
let myChildViewController = MyChildViewController()
myChildViewController.delegate = self //we set the delegate to point to ViewController
tabController.set(viewController: myChildViewController, atIndex: 0)
So now every time you wish to hide the tab bar you can do so by doing:
self.delegate?.requestTabVisability(show: true,animate: true)
I hope this helps you solve your problem, if you have any question feel free to ask 😄
@ElyDantas Was your issue resolved?
Yes, it worked like a charm !!! Thx, now it is more design pattern driven.
Glad to help.
How to access AZTabBar from another ViewController class ?
I want to hide tabbar when button is clicked in another viewcontroller storyboard/class