隐藏Boom Bar on Push是导航栏的原因

时间:2017-06-17 09:08:44

标签: ios objective-c swift uinavigationcontroller uitabbarcontroller

当我推送详细的View Controller时,我有一种奇怪的行为。

enter image description here

我有这样的层次结构View Controllers,默认配置所有控制器。

View hierarchy

只有最后一个UIViewController设置hidesBottomBarWhenPushed = true

以下是Google云端硬盘中的test project。我测试了XCode 8,iOS 10,模拟器iPhone SE

感谢您的帮助!

2 个答案:

答案 0 :(得分:2)

以下代码段可以解决您的问题

self.navigationController?.navigationBar.isTranslucent = false

将上述代码添加到viewDidLoad

TableViewController

如果您希望navigationBarisTranslucent = true一起使用,则可以更改window backgroundColor颜色,如下所示

self.window?.backgroundColor = UIColor.white

答案 1 :(得分:0)

我很长时间都在处理相同的错误,但偶然发现了奇怪的解决方法。诀窍是:

  1. 在标签栏上设置 clear backgroundView,这会导致视图控制器的布局不同
  2. 在第一个按钮下方设置一个新的 BlurEffect 视图
  3. 将模糊视图限制为 tabBar (UIView)

在我使用 tabBar 的快照并将 tabBar 的 alpha 设置为 0 之前,但这会导致不需要的 safeLayoutGuide 偏移。由于此解决方案现在可以访问任何私有变量,因此我希望访问 AppStore 是绿色的(我还没有到那里)。

在我的 UITabBarController 的 viewDidLoad 中,我设置了以下内容:

tabBar.backgroundImage = UIImage()
let blurView = UIVisualEffectView()
blurView.effect = UIBlurEffect(style: .systemChromeMaterial)
blurView.frame = tabBar.bounds
blurView.translatesAutoresizingMaskIntoConstraints = false
blurView.isUserInteractionEnabled = false
tabBar.insertSubview(blurView, belowSubview: tabBar.subviews.first!)
let leadingConstraint = blurView.leadingAnchor.constraint(equalTo: tabBar.leadingAnchor, constant: 0)
let trailingConstraint = blurView.trailingAnchor.constraint(equalTo: tabBar.trailingAnchor, constant: 0)
let topConstraint = blurView.topAnchor.constraint(equalTo: tabBar.topAnchor, constant: 0)
let bottomConstraint = blurView.bottomAnchor.constraint(equalTo: tabBar.bottomAnchor, constant: 0)
NSLayoutConstraint.activate([leadingConstraint, trailingConstraint, topConstraint, bottomConstraint])

或:

//Setting background image to empty image to prevent a bug under top right navigation bar corner
tabBar.backgroundImage = UIImage()
//As that turns of the blur effect I am adding a new view imitating the same
let blurView = UIVisualEffectView()
blurView.effect = UIBlurEffect(style: .systemChromeMaterial)
blurView.frame = tabBar.bounds
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
blurView.isUserInteractionEnabled = false
tabBar.insertSubview(blurView, belowSubview: tabBar.subviews.first!)