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

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