Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tab bar color become black when hidden swift

enter image description here

as you can see from the picture, the tab bar color is black. I hide the tab bar when segmented control tapped

@IBAction func segmentedControlTapped(sender: AnyObject) {
    if segmentedControl.selectedSegmentIndex == 1 {
        self.viewUIPickerView.viewWithTag(10)?.hidden = false
        self.viewUIPickerView2.viewWithTag(11)?.hidden = true
    }else {
        self.viewUIPickerView2.viewWithTag(11)?.hidden = false
        self.viewUIPickerView.viewWithTag(10)?.hidden = true
    }

    self.tabBarController!.tabBar.hidden = true

}

and i try usinghidesBottomBarWhenPushed = true still doesnt work.

like image 418
Ariel Gemilang Avatar asked Jul 14 '16 02:07

Ariel Gemilang


2 Answers

Swift 4: Programatically

Worked Perfectly for me.

func hideTabBar() {
    self.tabBarController.tabBar.isHidden = true
    self.tabBarController.tabBar.isTranslucent = true
}

func showTabBar() {
    self.tabBarController.tabBar.isHidden = false
    self.tabBarController.tabBar.isTranslucent = false
}
like image 81
Himanshu padia Avatar answered Sep 18 '22 13:09

Himanshu padia


You are using hidesBottomBarWhenPushed in the view with the tab controller. But you must set this in the controller that you will push.

Set it into prepare for segue

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    segue.destination.hidesBottomBarWhenPushed = true
}
like image 26
Haroldo Gondim Avatar answered Sep 17 '22 13:09

Haroldo Gondim