Search code examples
swiftuiviewuinavigationbaruistatusbar

UIView above NavigationBar and StatusBar


I need to show UIView with full screen mode above NavigationBar and StatusBar How i can do that?


P.S. Sorry for my English

View above NavigationBar and StatusBar


Solution

  • The below code will help you with that. You can change the color to your desired color to achieve the desired affect.

    UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
    
    UIView *blue = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [blue setBackgroundColor:[UIColor blueColor]];
    [window addSubview: blueView];
    

    Swift Code:

    if let applicationDelegate:AppDelegate = UIApplication.shared.delegate as! AppDelegate? {
       if let window:UIWindow = applicationDelegate.window {
          let blueView:UIView = UIView(frame: UIScreen.main.bounds)
          blueView.backgroundColor = UIColor.blue.withAlphaComponent(0.75)
          window.addSubview(blueView)
       }
    }