如何用子视图掩盖状态栏?

时间:2017-05-19 20:52:08

标签: ios swift uinavigationcontroller

所以我将子视图(侧面菜单)拉出导航控制器内部主视图的顶部。是否可以隐藏滑出菜单上的状态栏,但继续在主视图上显示它?

注意:一个视图目前位于另一个视图之上

So I have the subview (side menu) pulled out on top of the main view inside of a Navigation Controller. Is it possible to hide the status bar on the slide out menu but continue to show it on the main view?

2 个答案:

答案 0 :(得分:0)

override var prefersStatusBarHidden: Bool {  
return true  

}

试试这个...... Can't Hide Status Bar—Swift 3,

答案 1 :(得分:0)

您可以在条件中隐藏状态栏。您需要在状态栏上添加另一个窗口对象。

    let stautsBarWindow = UIWindow(frame: UIScreen.main.bounds)
    stautsBarWindow.backgroundColor = UIColor.clear
    stautsBarWindow.rootViewController = yourSideMenuViewController
    stautsBarWindow.windowLevel = UIWindowLevelStatusBar
    stautsBarWindow.isHidden = false

这将在状态栏的顶部创建另一个窗口对象。因此,只需将其向左侧滑动,这样您就可以只看到它的一半/将其宽度减小到屏幕的一半,这样您就只能看到一半可见区域并在此区域内显示完整的viewController。你认为哪种逻辑是正确的只是使用它。