Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Example/Code/Code/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
19 changes: 18 additions & 1 deletion KYDrawerController/Classes/KYDrawerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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:
Expand Down