     return nil
   }
 }
+
+private struct StatusBarState {
+  let hidden: Bool
+  let style: UIStatusBarStyle
+  
+  static var defaultStatusBar: StatusBarState {
+    return StatusBarState(hidden: false, style: .LightContent)
+  }
+}
+
+private extension UIWindow {
+  var currentStatusBarState: StatusBarState {
+    if let rootViewController = self.rootViewController {
+      let topMostViewController = rootViewController.findTopMostController()
+      let viewControllerForStatusBarHidden = topMostViewController.childViewControllerForStatusBarHidden() ?? topMostViewController
+      let viewControllerForStatusBarStyle = topMostViewController.childViewControllerForStatusBarStyle() ?? topMostViewController
+      return StatusBarState(hidden: viewControllerForStatusBarHidden.prefersStatusBarHidden(),
+                            style: viewControllerForStatusBarStyle.preferredStatusBarStyle())
+    }
+    else {
+      return StatusBarState.defaultStatusBar
+    }
+  }
+}
+
+private extension UIViewController {
+  func findTopMostController() -> UIViewController {
+    var topController: UIViewController = self
+    while let presentedViewController = topController.presentedViewController {
+      topController = presentedViewController
+    }
+    return topController
+  }
+}

    super.viewDidLoad()
    view.backgroundColor = UIColor.clearColor()
  }
}

private extension SequenceType {

  public func showSystemViewController(viewController: UIViewController, atLevel level: SystemViewControllerLevel) {
    if !window.keyWindow { showSystemWindow() }
    
    self.viewController.showSystemViewController(viewController,
                                                 atLevel: level, statusBarState: previousKeyWindowStatusBarState)
  }
  
  /**
