hide / show tab bar when push / back. swift

前端 未结 4 2170
甜味超标
甜味超标 2020-12-05 16:46

Answer: Use self.tabBarController?.tabBar.hidden instead of hidesBottomBarWhenPushed in each view controller to manage whether the view controller should show a tab

4条回答
  •  广开言路
    2020-12-05 17:16

    As it's name suggest, hiddenBottomBarWhenPushed only hide bottom bar if needed, it will not unhide bottomBar. You can do this to get it works:

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        self.tabBarController?.tabBar.hidden = true/false
    } 
    

    or simply put self.tabBarController?.tabBar.hidden = true/false in prepareForSegue

    But I would not recommend you to do so, as it would be weird if bottomBar suddenly popped out, user will thought they suddenly back to rootViewController while they are not.

    Users should always know where they are in your app and how to get to their next destination.

提交回复
热议问题