IOS status bar not translucent - ios

I have a navigation view controller. The root view hides the navigation bar using self.navigationController?.navigationBarHidden = true.
No matter what I do I cannot get thestatusBar to be translucent it is simply a white block that pushes my content below.

You can make status bar translucent as -
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
// set full screen layout in view controller class
self.wantsFullScreenLayout = YES;

Related

Show View on the top of navigation bar

I have a custom navigation and Home view in my app. On the click of button I want to show a View just like a left side view ( width is not equal to screen width) , on the top of navigation.
I have tried this:
LeftView.Layer.ZPosition = 1;
It is not working. If I set the Z index of navigation to -1, this hides complete navigation bar.
Try this :
[self.navigationController.view addSubview:yourSubView];
Try to add that view to UIWindow. This will add your view above navigation bar.
[[[[UIApplication sharedApplication] delegate] window] addSubview:yourView];
Add your custom navigation bar to the main view manually instead of using navigation controller's standard navigation bar. Then add your leftview as subview, in your main view. It will overlap navigation bar in this hierarchy.
This is a correct answer:
[self.navigationController.view addSubview:yourSubView];
Though it will not set the correct frame for the view, To set the correct frame for your view on the navigation bar, you have to set it in the viewDidAppear.
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.navigationController.view addSubview:mTitleView];
}

Set status bar colour for different view controllers

I have 6 view controllers. I'd like to set the status bar of my first view controller to black and then the other 5 to white. All view controllers are in a push stack.
I've tried to implement
[self setNeedsStatusBarAppearanceUpdate]
- (UIStatusBarStyle) preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
That does not seem to work. I've also tried playing with the apps plist properties. Any ideas?
If you want to change Background colour of status bar then that's possible.
you have to change UIWindow 's background colour to your preferred colour. try following
e.g.
[[UIApplication sharedApplication].delegate window].backgroundColor = [UIColor orangeColor];
and if you want to change text colour then just try
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
You have missed this settings in Plist
View controller-based status bar appearance to YES
Do the following things.
View controller-based status bar appearance = NO in plist.
The ViewController that you want to make white in ViewwillApper add
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
The ViewController that you want to make Black in ViewwillApper add
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

UINavigationBar has wrong height because the status bar is hidden while loading

I have set a UITabBarController as the root view controller in the AppDelegate.
I have added a loading view upon the window, while the app downloads some data. I have hidden the status bar while the loading screen is visible. As soon as the loading is done, I fade the loading view and shows the status bar again.
My problem is that when I show the status bar the navigation bar was not drawn to have the right height, because the status bar was hidden when it was drawn. If I change to another tab it gets the right height.
I have tried with [navigationController.view setNeedsLayout], but that seems to get the position of the view of the ViewController right, but the content of the navigation bar does not resize. I have also tried with [navigationController.navigationBar setNeedsLayout], but that does help at all.
So I basically want to get the navigation drawer get the right height for the status bar and content when the loading view fades. How can I do this?
Have you try to reset the navigation and status bar as like below?
-(void)resetNavigationBar
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
[self.navigationController setNavigationBarHidden:YES];
[self.navigationController setNavigationBarHidden:NO];
}
I would unhide the status bar in the viewWillDisappear: method on the loading view.
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}

UIModalViewController StatusBar background color

I set an UINavigationBar background tint by appearance using macro color:
[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x6DBEE8)];
And in whole navigation based application but in my UIModalViewController does not work:
In my plist i have : View controller-based status bar appearance : YES
and globally i set appearance : [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Here it what it's look like:
That is because in iOS7, the height of UINavigationBar is increased (64 points) when it is contained in a UINavigationController. With the status bar being transparent,when you are presenting a view controller modally, its not in the UINavigationController so the height is normal (44 points) and thus the map view is behind the status bar. You need to handle this in your modal view controller. You can:
Hide the status bar altogether (works but might not be preferable in
every situation)
Put a view behind the navigation bar and where the status bar is with
the same background color.
Change the color of the view controller's view itself to the desired color and
offset the y position of your map view to accommodate the status
bar's height.

Hide UINavigationBar but still show Status Bar

How can I hide the navigation bar by not hiding the status bar in my app? When I try [self.navigationController.navigationBar setHidden:YES]; it also hides the status bar. I need to show the status bar like this:
I need to first hide a visible navigation bar, make the status bar still visible and I also have a view that I need to move below the status bar, but the view is being positioned like the navigation bar is still there when I set the frame's position to 0,0.
I setup my statusbar as:
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Add this to your code where you want to hide the navigation bar
[self.navigationController.navigationBar setHidden:YES];
If you want to hide navigation bar but show status bar, you should set Top Space to Top Layout Guide as 0 instead of -44. and then
Hide navigation bar in viewWillAppear instead of viewDidLoad: [self.navigationController setNavigationBarHidden:YES animated:YES]
I start to set top space as -44, then call method [[UIApplication sharedApplication] setStatusBarHidden:NO], it doesn't work.
In my case, the status bar text and symbols were not shown because they had the same color as the background (black). I solved the problem by changing the background color:
[self.navigationController.navigationBar.superview setBackgroundColor:UIColor.whiteColor];

Resources