Swift navigation bar under status bar - ios

Here is what my navigation bar and status bar look like:
How do I prevent the navigation bar going under the status bar without using a navigation controller?

EDITED
Check this image, you need to add a constraint on top to View to 0 and height = 64, and this is it
I hope this helps

Related

Hide status bar without automatically adjusting a navigation bar's frame

When hiding the status bar in a UINavigationController-based app by using:
UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: .None)
the UINavigationBar's frame is adjusted. This is because the status bar is a UIView itself and the top of the navigation bar is constrained to the bottom of the status bar. So when the status bar is moved offscreen, the navigation bar moves up with it.
I've tried a number of ways to prevent this behavior. I've tried manually assigning a frame to the navigation bar to no avail. I've tried subclassing UINavigationBar and overriding sizeThatFits() while checking if the status bar is hidden or not and assigning a frame that way. Nothing. I've read other SO posts but no one seems to have a working solution. Help?

How to give automatically top space to navigation bar in ios?

I have a UIViewController. I am designing the screen for iPhone 5s. I have a UIImageView & I am giving top space to container of 20. I also have UINavigationBar at top.So the space given of 20 is not enough. UIImageView is hidden behind the UINavigationBar. I can resolve this issue by giving much space from top. But in that case at design time my UI will not look proper. So is there any way by which space from UINavigationBar is automatically calculated?
In Attribute Inspector set Top Bar to Translucent Navigation Bar like this
then set Top Space of imageView to Top Layout Guide like,
set navigation bar type as opaque Navigation Bar so it will opaque that much space from your view controller and show your view content after navigation bar space they will not hide inside of navigation bar.
but if you set navigation bar type as Translucent Navigation bar then your content will hide inside of navigation bar so set "Opaque Navigation Bar" type. no need to do any other stuff for that.
I hope it will help you!

How to set the status bar to look like the system message app in iOS?

First, look at the picture below.
The middle is the message app, the left and right are my apps.
As you can see, in the message app, the status bar and top bar are both grey.
In the left one, the top bar is not translucent. The status bar and the top bar are all white.
In the right one, the top bar is translucent, which is the default style. The top bar is grey, but the status bar is white.
My question is, how to set the status bar to grey? As I can see in the target info part, the status bar style is already 'grey style(default). But it runs in white in my iPhone 5 iOS 7.1.1.
It turns out that #Panayot Panayotov is right. In Navigation controller, everything is fine.
I have compared the Navigation controller and Navigation bar alone. It turns out that in Navigation controller, the Navigation bar's x, y, width and height is 0, 0, 0, 0, which means it is right behind the status bar and also with a autolayout size. Since the status bar is translucent in iOS7, the color of the status bar and navigation bar are the same.
If you use Navigation bar alone, it has a fixed height 44, which can not be changed. That height can't cover the status bar and navigation bar items together. So they colors are different.
Finally the answer is to use navigation controller, not using navigation bar alone.

iOS 7 navigation bar style to look like navigation controller nav bar

When using the navigation controller or embedding a view controller in navigation controller, the navigation bar light grey color covers the status bar also (the carrier, time, battery, etc). When dragging a navigation bar onto the view controller, the status bar is still white. You can't change the height of the navigation bar...so how can I make everything look and feel the same? Here's the two images:
As you can see, Chat shows that white space above the nav bar, whereas Social doesn't...any workout for this?
In this case navigation bar looks like non-transparent.
Please check properties of navigation bar and/or initialization of this bar to be sure that it's transparent.

UIView is not autoresized after I hide the UIStatusBar

I have a ViewController which need to hide the status bar sometimes. The problem is the view of the UIViewController is not autoresized after the status bar is hidden. (Actually I have another application use the exactly the same View Controller. Which has no problem at all). Can anybody advise which could be the cause of the problem? Thanks
Please refer to my screen shots. The first one is the view before I hide the status bar and the navigation bar. The second one is after I hide the status bar and navigation bar. You can see that the there is obvious black area which previously occupied by status bar.
Seems wantsFullScreenLayout of your view controller isn't set to YES.
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[self setWantsFullScreenLayout:YES];
Try this in your viewDidLoad.
Additionally to full screen layout I think the bar style must be traslucent.

Resources