I'm all out of ideas on how to get this to work.
I need the status bar to match the colour of the Nav bar, with the Nav bar being transparent.
For some reason however, it's only working for 3 quarters of the status bar.
Here it is in portrait. With the slide in masterView's status bar being black.
And landscape. No idea why it's black at the far right.
Does anyone know why it would be doing this? The status bar is supposed to take on the colour of the navigation bar. But it just isn't working.
I've tried setting background images to the Navigation Bars.
I've tried setting a colour to the Navigation Bar background.
This is the code in my AppDelegate that adds the blue to the status bar.
UIView *statusBarBlue = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.window.frame.size.width, 20)];
[statusBarBlue setBackgroundColor:[UIColor colorWithRed:0.219 green:0.554 blue:0.719 alpha:1.000]];
[self.window.rootViewController.view addSubview:statusBarBlue];
Opening up a new project and pasting that code in to your AppDelegate will get the same thing I'm seeing.
If I extend the width of the statusBarBlue view, to say like 2000, the black status bar in the landscape is removed.
However, in portrait, the black is still there.
I'm all out of ideas. Any nudges in the right direction would be very helpful.
I managed to get this to work by just setting the navigation bar colour.
Related
Is there away i can set the colour of may navigationController bottom bar colour. Similar to setting top bar in the app delegate with
[[UINavigationBar appearance]setBackgroundColor:color];
can bottomBarColor or something be used?
thanks
The problem is you mistakenly believe that the bar you see at the bottom is a real bar instance/object.
It is not, it is just a simulation of a future situation.
With bar metrics feature in Interface Builder, you can simulate a situation when you view controller will be a part of larger view hierarchy which will contain a bar at a bottom. You can simulate this in design time, and this way you can adjust your AutoLayout constraints, or frames, as if the bar was there so this way the constraints/ frames will behave correctly when it really happens.
If you want a bar with orange colour, you need to have a real bar instance added to some view controller, and change its appearance. But I repeat, it needs to be a real bar instance, not a bar metrics simulation.
Btw, it is AFAIK not possible to put a navigation bar to the bottom, for that you need to use UIToolbar class.
If you want to set the toolbar color globally do this in your AppDelegates didFinishLanchingWithOptions method:
[[UIToolbar appearance] setBarTintColor:[UIColor blackColor]];
Of course your selected color doesn't have to be black.
I'm manually hiding the navigation bar based on the scroll offset of the scrollview and it works 100% fine with a translucent navbar. However, if it's opaque (I need it to be to get the background colour correct), it produces this black bar which I can't seem to get to go away.
I have a custom UINavigationBar which I am using to remove the gradient of the navbar in iOS 6. Though the color of the status bar is equal to the color of the screen opposed to the color of the bar
Is there a way to make them the same color or at least make the status bar black. My problem is in ios7.
Also if I change the style of the UINavigationBar translucent to NO like this:
self.navigationController.navigationBar.translucent = NO;
Then the status bar goes completely black with no writing on it.
In your project info plist, change UIViewControllerBasedStatusBarAppearance value, if there is no, then add this key.
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.
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.