Transparent Black Shade over the Navigation Bar in iPhone-X Later Notch Screen Devices in iOS App

198 views Asked by At

I've configured app to support Notch Screen devices Running my App in the iPhone X Simulator.

the App is working fine in Normal views but does not use the full screen space if I have NAVIGATION CONTROLLERS

a strange Transparent Black Shade is appearing over the Navigation bar

Does anybody help me on this what is happening here and how to resolve this? I can't find any new settings in Interface Builder.

2

There are 2 answers

1
KAREEM MAHAMMED On BEST ANSWER

HI Please add the below code in Appdelegate did finish launch

if (@available(iOS 13.0, *)) {

        UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame];

        if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {

            statusBar.backgroundColor = [UIColor whiteColor];

        }

        [[UIApplication sharedApplication].keyWindow addSubview:statusBar];



    } else {
        UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.frame];

        if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {

            statusBar.backgroundColor = [UIColor whiteColor];

        }

    }
0
Fabio On

Try to set status bar background color with the same color of navigation controller, add this extension:

extension UINavigationController {

func setStatusBar(backgroundColor: UIColor) {
    let statusBarFrame: CGRect
    if #available(iOS 13.0, *) {
        statusBarFrame = view.window?.windowScene?.statusBarManager?.statusBarFrame ?? CGRect.zero
    } else {
        statusBarFrame = UIApplication.shared.statusBarFrame
    }
    let statusBarView = UIView(frame: statusBarFrame)
    statusBarView.backgroundColor = backgroundColor
    view.addSubview(statusBarView)
  }
}

Now in viewDidLoad call:

navigationController?.setStatusBar(backgroundColor: .yourColor)