在横向模式下旋转后,状态栏左侧为白色矩形

时间:2018-08-02 07:50:47

标签: ios swift statusbar landscape

我的VC和UIView带有隐藏的导航栏,

self.navigationController?.setNavigationBarHidden(true, animated: animated)

在顶级VC中,我的视图受约束View.top = SafeArea.Top

在纵向模式下-一切正常。但是当旋转到横向模式状态栏时,VC会像白色矩形一样留在VC中。

我不需要横向显示状态栏。如何删除?为什么状态栏会留下这个标签?

2 个答案:

答案 0 :(得分:0)

我已经根据您的情况实现了代码,对我来说很好。我认为这是xcode / compiler的问题。您可以这样做:

  1. 将主视图的clipToBounds属性设置为true。
  2. 隐藏情节提要中的导航栏:选择NavigationController,打开身份检查器,取消选中显示的导航栏选项

答案 1 :(得分:0)

抱歉! 我找到原因了。 这是一个自定义视图,用于为状态栏着色。

添加此视图的示例。

let statusBarView = UIView(frame: UIApplication.shared.statusBarFrame)
let statusBarColor = UIColor(r: 240, g: 243, b: 245)
statusBarView.backgroundColor = statusBarColor
view.addSubview(statusBarView)

谢谢大家!