Search code examples
iosuistatusbarchildviewcontrollerios7-statusbarchildviews

Is there any way to cover an iOS 7 status bar with a UIView temporarily?


I have a bit of a weird scenario here and have been trying to find some help but the solutions don't really solve my problem rather make it worse.

I have a container viewController that has three child controllers views inside a horizontal scroll view. My default child controller view is my custom camera page. Now this is what I want to achieve. I would like to keep the status bar hidden on my camera page but would like the other two views aka my other two child controllers to have the status bar showing.

When I drag from either my left child controller to my camera page or from my right child controller to my camera page, I would like my camera page view to overlap the status bar.

The only place I have seen this done is on Snapchat and I've been trying for a couple hours to figure it out but just can't seem to come up with a solution. Any help is appreciated.


Solution

  • You can do it wizh the real Statusbar. Just get the Statusbars UIView you then need to play with the UIWindowLevel like this

        //Getting the Statusbar
    
        UIView *statusbar;
        NSString *key = @"statusBar";
        id object = [UIApplication sharedApplication];
        if ([object respondsToSelector:NSSelectorFromString(key)]) {
            statusbar = [object valueForKey:key];
        }
    
        //Set your Overlapping UIViewController or UIView one Level higher then the Statusbar.
        self.navigationController.view.window.windowLevel = UIWindowLevelStatusBar+1; //This will set the Overlapping UIViewControllers WindowLevel over the StatusBar.