iOS中的自定义导航抽屉中状态栏颜色是否变为白色?

Tec*_*ain 7 xcode statusbar ios swift

我在swift中创建了一个自定义导航抽屉.我使用了app delegate中的窗口并添加了关于挡风玻璃的视图.我隐藏后显示按钮单击视图.

下面的代码创建抽屉.

func setupSideMenu(){

        windowSideMenu = ((UIApplication.shared.delegate?.window)!)!
        windowSideMenu.backgroundColor = UIColor.black
        if customView == nil {
            print("custom view nil")
            // Register Swipe gesture for opening slideMenu
            let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.openSideMenu))
            swipeRight.direction = UISwipeGestureRecognizerDirection.right
            self.view.addGestureRecognizer(swipeRight)

            /// Register Drawable NIB here only for once
            customView = SideView.instanceFromNib() as! SideView
            customView.configureDrawer()
            customView.navigationController = self.navigationController
            customView.frame = CGRect(x: -customView.frame.size.width, y: -10, width: self.view.bounds.size.width - 30, height:UIScreen.main.bounds.height)
            customView.drawerDelegate = self

            /// BackView (DimView)
            backView.frame = self.view.frame
            backView.backgroundColor = UIColor.black
            backView.alpha = 0.4
            backView.isHidden = true
            self.view.addSubview(backView)
            let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.closeSideMenu))
            backView.addGestureRecognizer(tapGesture)
            customView.isHidden = true
            windowSideMenu.addSubview(customView)
            windowSideMenu.makeKeyAndVisible()

        }
    }
Run Code Online (Sandbox Code Playgroud)

在隐藏和显示我改变窗口级别UIWindowLevel.

  override func openSideMenu() {
        super.openSideMenu()
        self.windowSideMenu.windowLevel = UIWindowLevelStatusBar
    }

    override func closeSideMenu() {
        super.closeSideMenu()
        self.windowSideMenu.windowLevel = UIWindowLevelNormal

    }
Run Code Online (Sandbox Code Playgroud)

但是当我改变窗口UIWindowLevelStatusBar级别时,状态栏的颜色设置为白色.

这是抽屉的屏幕截图 在此输入图像描述

对不起,我不得不改变一些颜色,因为我无法显示整个设计.

Mal*_*lik 1

也许是因为你的SideView背景是白色的。尝试在故事板中更改它

  • 我很困惑。您到底想在这里实现什么目标?您允许自定义视图覆盖状态栏区域。自定义视图是白色的。您不想更改自定义视图的颜色,但也不希望状态栏为白色。我在这里缺少什么? (2认同)