diff --git a/Example/Code/Code/AppDelegate.swift b/Example/Code/Code/AppDelegate.swift index 6da9ca7..e4d6412 100644 --- a/Example/Code/Code/AppDelegate.swift +++ b/Example/Code/Code/AppDelegate.swift @@ -32,7 +32,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let mainViewController = MainViewController() let drawerViewController = DrawerViewController() - let drawerController = KYDrawerController(drawerDirection: .left, drawerWidth: 300) + let drawerController = KYDrawerController(drawerDirection: .left, drawerWidth: 300, hideStatusBar: true) drawerController.mainViewController = UINavigationController( rootViewController: mainViewController ) diff --git a/KYDrawerController/Classes/KYDrawerController.swift b/KYDrawerController/Classes/KYDrawerController.swift index 0e2d026..658d102 100644 --- a/KYDrawerController/Classes/KYDrawerController.swift +++ b/KYDrawerController/Classes/KYDrawerController.swift @@ -78,6 +78,8 @@ open class KYDrawerController: UIViewController, UIGestureRecognizerDelegate { public var screenEdgePanGestureEnabled = true + public var hideStatusBar: Bool = false + public private(set) lazy var screenEdgePanGesture: UIScreenEdgePanGestureRecognizer = { let gesture = UIScreenEdgePanGestureRecognizer( target: self, @@ -246,10 +248,11 @@ open class KYDrawerController: UIViewController, UIGestureRecognizerDelegate { // MARK: - initialize /**************************************************************************/ - public init(drawerDirection: DrawerDirection, drawerWidth: CGFloat) { + public init(drawerDirection: DrawerDirection, drawerWidth: CGFloat, hideStatusBar: Bool = false) { super.init(nibName: nil, bundle: nil) self.drawerDirection = drawerDirection self.drawerWidth = drawerWidth + self.hideStatusBar = hideStatusBar } required public init?(coder aDecoder: NSCoder) { @@ -347,9 +350,23 @@ open class KYDrawerController: UIViewController, UIGestureRecognizerDelegate { animations: { () -> Void in switch state { case .closed: + if self.hideStatusBar { + DispatchQueue.main.async(execute: { + if let window = UIApplication.shared.keyWindow { + window.windowLevel = UIWindowLevelNormal + } + }) + } self._drawerConstraint.constant = 0 self._containerView.backgroundColor = UIColor(white: 0, alpha: 0) case .opened: + if self.hideStatusBar { + DispatchQueue.main.async(execute: { + if let window = UIApplication.shared.keyWindow { + window.windowLevel = UIWindowLevelStatusBar + 1 + } + }) + } let constant: CGFloat switch self.drawerDirection { case .left: