首页 > 解决方案 > 在 Swift 4 中,如何正确隐藏 tabBar?

问题描述

如何使用“hidesBottomBarWhenPushed”正确隐藏 UITabBarController 的 tabBar?

视图控制器A:

hidesBottomBarWhenPushed = true

这成功隐藏了 tabBar,但即使 viewControllerA 从 viewControllerB 弹出,它也会永久隐藏。

标签: swiftuitabbarcontroller

解决方案


You can simply use this in your ViewDidLoad() method.

self.tabBarController?.tabBar.hidden = true

For swift 3.0:

self.tabBarController?.tabBar.isHidden = true

Or you can change z position of tab bar this way:

self.tabBarController?.tabBar.layer.zPosition = -1

and if you want to show it again then:

self.tabBarController?.tabBar.layer.zPosition = 0

推荐阅读