0

I am trying to show UIView above all navigationBar , status bar.

I tried options like setting navigation z position , adding UIView to UIWindow and adding UIView to NavigationController.

Add a UIView above all, even the navigation bar

Nothing worked for me.

My Application is on xcode 9.2 ,swift 4.0 , ios 11.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
bhupinder
  • 315
  • 1
  • 6
  • 23
  • @the4kman Views can overlap statusbar. – bhupinder Mar 09 '18 at 13:42
  • 1
    @the4kman It's not an overlay, it's a system window. Technically, you can create a window that will be even above the status bar. There are also ways to access it dynamically but I would not advise to do that :) – Sulthan Mar 09 '18 at 16:22
  • 1
    @the4kman Not really, I saw apps that were showing notifications messages above the status bar. See https://github.com/cezarywojcik/CWStatusBarNotification. Note that Apple does not force you to show status bar, that's why you can hide it completely for view controllers. – Sulthan Mar 09 '18 at 16:30

1 Answers1

3

Add overlayView on main window:

if let window = UIApplication.shared.keyWindow {
    let overlayView = UIView()
    overlayView.frame = window.frame
    overlayView.backgroundColor = .red
    window.addSubview(overlayView)
}
Jay Patel
  • 2,642
  • 2
  • 18
  • 40