Reputation: 597
Currently I have a TabBarController with some tabs in it. However if I try to open another TabBarController with tabs as a popup (code below), the tabbars just stack. I have tried using TabBarcontroller?.tabbar.ishidden = false. But it just hides the previous tabbar, without removing the spacing. Like the new tabbar is above the hidden space (constraints still there). I just want it to popup overtop of the previous controller. Also in case you are wondering, I am opening the VC from one of the First Tabbar controllers. FYI, the tabbar backgrounds are clear so thats why they look like that.
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier:
"MyTabBarController") as! MyTabBarController
self.addChild(vc)
vc.view.frame = self.view.frame
self.view.addSubview(vc.view)
vc.didMove(toParent: self)
Upvotes: 0
Views: 112
Reputation: 1203
You are adding your MyTabBarController
as a child view, i.e. embed this controller in the existing one (self).
The reason the previous TabBar (or its spacing) is still there is, that self
isn't the previous TabBarController but one of the embedded tabs. The frame of these tab controllers do not include the TabBars frame.
E.g. if the TabBarVCs frame is (0, 0, 320, 640) and the TabBars frame is (0, 600, 320, 40), then the tab controllers frames are (0, 0, 320, 600).
To show your MyTabBarController
as a popup, i.e. covering your current vc without modifying it's views, just present the new vc like this:
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MyTabBarController") as! MyTabBarController
self.present(vc, animated: true, completion: nil)
Upvotes: 1