隐藏状态栏时,TabBarController中的NavigationController忽略topLayoutGuide

时间:2016-12-12 15:58:57

标签: swift uinavigationcontroller uitabbarcontroller ios10 uistatusbar

我有一个简单的测试应用程序设置如下:

UITabBarController ---> UINavigationController ---> [root to] --->的UIViewController

Storyboard setup

紫色条只是一个UIView,里面有一个按钮。这种观点的限制是:

Constraints

ViewController内的代码通过按钮切换状态栏:

<form>
<p><input type="checkbox" />Check Me to make the Text Box a Required Field</p>
<input type="text" />
<input type="submit" value="Submit" />
</form>
  • 故事板中的所有控制器都有&#34;在底栏下#34;和&#34;在 顶栏&#34;选择。
  • NavigationBar设置为isTranslucent = YES

问题:

使用此特定设置,当状态栏重新出现/向下滑动时,紫色UIView不会相应调整(topLayoutGuide)并且不会随状态栏向下移动,最终结果如下:

Example

然后它试图赶上并获得所有奇怪和抵消。如果我在动画块中调用强制更新,可以阻止这种情况发生:

@IBAction func updateStatusBar(_ sender: Any) {
    UIView.animate(withDuration: 0.5, animations: {
        self.setNeedsStatusBarAppearanceUpdate()
    })
}

override var prefersStatusBarHidden: Bool {
   return !UIApplication.shared.isStatusBarHidden
}

override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
    return .slide
}

但我当然不应该强迫这一点。

  • isTranslucent = false解决此问题,但我想要一个半透明的导航栏。
  • 如果我删除TabBarController
  • ,这种奇怪的行为不会发生

以下是我期望/希望拥有的行为:

How it should look

有什么想法吗?这是Apple开发人员忽视的错误,还是我错误地使用了框架?

0 个答案:

没有答案
相关问题