In a navigation controller, you automatically get the correct colour and position of a navigation bar as expected.
like this
But in modal view, when you drag in a navigation bar, you can position it right at the top, which is too close to the carrier / battery info.
So you can drag it down, guess how far so it matches the position of the automatically created one, but then you have a colour discrepancy. I have tried changing status bar settings in IB, doesnt make a difference.
Is there a correct way to do overcome this, as in make a modal view look like the auto generated nav view.
Thanks
In Swift:
The best way to overcome this in iOS 8.1 and Swift is by conforming to the new UIBarPositioningDelegate protocol.
You connect the delegate of your NavigationBar to your view controller and conform to that protocol and by calling the method:
You can remove the top gap in the view controller. You need to place the bar 20 points below the top edge.
After a few tries to move Navigation Bar few pixels down in iOS 7, this is what finally worked for me:
I also adjusted the Status Bar color to better match my content:
The best way to overcome this in iOS 7 is by conforming to the new
UIBarPositioningDelegate
protocol.You connect the delegate of your NavigationBar to your view controller (set your view controller as the delegate for the navigation bar either through storyboard or through code) and conform to that protocol and by implementing the method
You can remove the top gap in the view controller. You need to place the bar 20 points below the top edge
For Swift3 use following..
I created a Navigation Controller, deleted the "Root View Controller" that appeared with it. Then hold ctrl and drag the "Navigation Controller" on your View (delete the navigation bar you added manually before). Set the Navigation Controller as "Initial View Controller" and it works fine for me now.
Figured out the 3 options for solving this problem.
Option 1: Resize the Nav Bar
Option 2: Hide the Status Bar
For example, in the modal view where you want to hide the status bar
Add this method
In viewDidLoad add
Now, when you dismiss the modal view, and you want your status bar back. Add this in viewWillAppear
and this, but return NO this time
Option 3: Embed in Nav Controller
Select your modal view, just embed that in a Navigation Controller.