Fullscreen UIView with Status bar and Navigation Bar overlay on the top

Objective CIphone

Objective C Problem Overview


What is the proper way to implement the status bar and navigation bar that go on top of an UIView?

alt text

Objective C Solutions


Solution 1 - Objective C

Just set “wants fullscreen layout” in your view controller. That solves the problem for me.

self.wantsFullScreenLayout = YES;

Solution 2 - Objective C

In the screenshot above, there's a translucent status bar and a translucent navigation bar.

The status bar is set using

[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent];

The navigation bar is set using

theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

Solution 3 - Objective C

If you have a view controller inside a navigation controller, and you want to hide the status bar in order to have your viewController's view in full screen, you can always call :

[self.navigationController.view setNeedsLayout];

after hiding the status bar. But I personally think

[self setWantsFullScreenLayout:YES];

is a better way.

Solution 4 - Objective C

The best way I came up was this: when using a "complex" hierarchy of Tab bar containing navigation controllers, with one "detail" view being a full screen view.

In the app delegate just before the tab bar controller's view is added to the window, I added this:

tabBarController.view.frame = [[UIScreen mainScreen] bounds];

This will make the tab bar controller cover the entire screen, even below the area of the status bar. I had to offset heights of several views to +20px, notably the navigation bars.

Solution 5 - Objective C

Set the statusbar style as black translucent and navigation bar style as black translucent. If you are using a navigation-based application, in the MainWindow.xib check the status bar is hidden and navigation bar is hidden checkboxes.

When the user touches the screen, start a timer to see if this was a single tap or double tap. If a single tap, make the statusbar and navbar hidden = NO. and once user activity stops, start a timer again. after some time of no activity, make them hidden again.

Solution 6 - Objective C

step 1 Set the UIViewControllerBasedStatusBarAppearance to No in the plist

Then add the following code in did finish launch option

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {

   [application setStatusBarStyle:UIStatusBarStyleLightContent];

    self.window.clipsToBounds =YES;

    self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}

Please follow this code it worked for me

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionleonhoView Question on Stackoverflow
Solution 1 - Objective CJonathan SterlingView Answer on Stackoverflow
Solution 2 - Objective CAugustView Answer on Stackoverflow
Solution 3 - Objective CUnfalksterView Answer on Stackoverflow
Solution 4 - Objective CAlfonsView Answer on Stackoverflow
Solution 5 - Objective ClostInTransitView Answer on Stackoverflow
Solution 6 - Objective CPreejith augustineView Answer on Stackoverflow