Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Status bar color changed to white in custom navigation drawer in iOS?

I have created a custom navigation drawer in swift. I have used the window from app delegate & added a view on winddow. After i hide show the view on button click.

Below code to create drawer.

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()

        }
    }

On hide & show i change the window level UIWindowLevel.

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

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

    }

But when i change the windowlevel to UIWindowLevelStatusBar then the color of status bar is setting white.

Here is the screen shot for drawer enter image description here

Sorry i had to change some colors as i can't show the whole design.

like image 328
TechChain Avatar asked Nov 23 '17 05:11

TechChain


People also ask

How do I change the color of my status bar on my Iphone?

Go to the Storyboard. Select the View and in the Attributes Inspector change the Background Color to Light Gray. Build and Run the Project. The default style of the status bar is dark content.

How do I change the background color on my status bar?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.

How do I change the color of my status bar flutter on my Iphone?

If you want to change a status bar text color across your app, a theme is always the right choice for this kind of task. To do that, set brightness property in AppBarTheme to either Brightness. dark or Brightness.


2 Answers

As i came to understand the problem because of sidemenu to overcome this issue we have one library very easy to customize

To set or to change root, left or right view controllers or views, call:

sideMenuController.rootViewController = rootViewController
sideMenuController.leftViewController = leftViewController
sideMenuController.rightViewController = rightViewController

sideMenuController.rootView = rootView
sideMenuController.leftView = leftView
sideMenuController.rightView = rightView

Hope this will help you

like image 142
Ganesh Manickam Avatar answered Mar 03 '23 11:03

Ganesh Manickam


Maybe because your SideView has a white background. Try changing that in the storyboard

like image 42
Malik Avatar answered Mar 03 '23 12:03

Malik