简体   繁体   中英

Non-transparent Status Bar without displaying navigation bar

I am trying to hide navigation bar and have non-transparent status bar. However, somehow I have limitation to not to create UIView for status bar background.

The problem is that status bar becomes transparent after I set navigation bar hidden and it overlaps on tableview scroll.

-(void)viewWillAppear:(BOOL)animated
{
    [self.tableView reloadData];
    [[self navigationController] setNavigationBarHidden:YES animated:NO];
}

I am wondering how can I make the status bar non-transparent, without creating UIView for its background for only single UIViewController (not for all controllers because I want it to be transparent in some).

You can't, the status bar itself is always transparent. The alternatives from the HIG that are relevant to you:

  • Display a custom image, like a gradient or solid color, behind the status bar.
  • Place a blurred view behind the status bar. For developer guidance, see UIBlurEffect.

You mention table view scroll. Could be that you have UITableViewController, meaning you cannot add a subview to viewController.view. You can create a custom container view controller that adds the view under the status bar, see the section Implementing a Container View Controller in the UIViewController documentation . You then nest your nest your view controller in this container.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM