Providing a navigation bar to overlapping the status bar in iOS 7

I want to create an application that uses the navigation bar, but only to display the name and some buttons (using the vie container). I want the navigation bar to merge with the status bar, for example,

Navigation Bar and Status Bar

But when I use the general view controller and drag the navigation bar, it looks just like this:

Without

Is there any way to do this?

+4
source share
5 answers

I found a solution for this particular problem. Set the transparent property of the navigation bar to NO:

self.navigationController.navigationBar.translucent = NO; 
+3
source

Not sure if this will fix your problem, but you can try what I did.

I had the same problem in the representation of the right-hand menu "Simulated metric"> Top panel> "Opaque navigation bar"

0
source

The UINavigationController will change the height of its UINavigationBar to 44 points or 64 points depending on a rather strange and undocumented set of constraints. If the UINavigationController detects that the top of its view is visually adjacent to the top of the UIWindows, then it draws its navigation bar with a height of 64 points. If its top view does not touch the top of UIWindows (even if it is turned off by only one point), then it draws its navigation panel in the "traditional" way with a height of 44 points. This logic is executed by the UINavigationController, even if multiple children are within the hierarchy of the view controller of your application. There is no way to prevent this behavior.

Full explanation here .

0
source
  • viewcontroller.h file in creating iboutlet navigation bar

    @property (weak, nonatomic) IBOutlet UINavigationBar *navBar;

  • You can do the following in viewDidLoad

    UIView * addStatusBar = [[UIView alloc] init];

    // display the status bar with the device width addStatusBar.frame = CGRectMake (0, -20, self.view.frame.size.width, 20);

    // set the background color in the status bar

    addStatusBar.backgroundColor = [UIColor colorWithRed: 24.0 / 255. green: 24/255. blue: 24.0 / 255. alpha: 1];

    [self.view addSubview: addStatusBar];

    // add your status bar to the UINavigationBar * navBar, which is specified in your file .h [self.navBar addSubview: addStatusBar];

0
source
 navigationController.navigationBar.clipsToBounds = YES; 

In order UINavigationBar increase its background in the status bar, its clipsToBounds must be set to NO (default). Make sure you don’t mock him.

The solution is simple: -

 navigationController.navigationBar.clipsToBounds = NO; 
0
source

Source: https://habr.com/ru/post/1498412/


All Articles