In some devices as iPhone 7 and 8 the navigation bar overlaps status bar after do navigating, the parent view controller has status bar hidden but I show and hide it in viewWillAppear and viewWillDisappear respectively. I tested in iOS 12 and it works.
I am using prefersStatusBarHidden to hidden the status bar.
Here the Image
Navbar Overlaps Status bar
Update:
Here an example project: https://github.com/FranklinSamboni/NavBarTestSwfit.
It work fine in iOS 12 but with iOS 13 the navigation bar overlaps status bar in iPhone 7,8
Images with iPhone 8 (simulator)
Home
The second view
Second View
Okay, I'm going to give one of those wishy-washy answers.
On the one hand, you've definitely found a new behavior in iOS 13. When you hide the status bar, the navigation bar shrinks. You could term this a bug in iOS 13...
On the other hand, it could be argued that what you are doing is wrong. If you have a navigation bar, you already cannot hide the status bar on a device without a bezel (iPhone X etc.), and now Apple seems to be assuming that if you have a navigation bar you won't hide the status bar at all. And that is a reasonable assumption, because it makes no sense to hide the status bar in portrait when there is a navigation bar, and especially in some children of the navigation controller but not others.
So you could file a bug report on this, but I don't think you'll get any joy from it. Apple is likely to reply that this is intended, or is at least a consequence of doing something they don't want to support. You have a navigation bar; allow the status bar to show.
I faced the same problem, after a few hours research, I found a not perfect but worked solution. Hope it will work for you.The code was written with Objective-C.
In viewDidAppear method of the secondViewController, hide statusBar first and show it at once.
Declare a member variable BOOL statusBarHidden in secondViewController
Implement prefersStatusBarHidden method from UIViewController
- (BOOL)prefersStatusBarHidden
{
return statusBarHidden;
}
Create a new method setStatusBarHidden
- (void)setStatusBarHidden:(BOOL)hidden
{
if (statusBarHidden != hidden)
{
statusBarHidden = hidden;
[self setNeedsStatusBarAppearanceUpdate];
}
}
Call setStatusBarHidden in viewDidAppear
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self setStatusBarHidden:YES];
[self setStatusBarHidden:NO];
}
Related
I made UIViewController which have navigationController as parent (connected in storyboard),
and I want to apply picture of navigationBar for statusBar background.
but it seems that statusBar can't be state like "Translucent",
I tried to set
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController.navigationBar setBackgroundImage:[UIImage
imageNamed:#"barTop.png"] forBarPosition:UIBarPositionTopAttached
barMetrics:UIBarMetricsDefault];
[self setNeedsStatusBarAppearanceUpdate];
....
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
in UIViewController.
But backgrounds of navigation and status Bar have been separated.
I try both to make plist file as "View controller-based status bar appearance" YES and NO. but still I can't configure statusBar from viewController.
I couldn't find same problem in this bulletin board .
does anyone knows solution??or how to debug?
thank you for reading.
(9/3 added: I want to make backgrounds together for navigationBar and statusBar.
And under the simple condition like that there are one navigationController and one ViewController, both bars can make their backgrounds together (default).
Now I met the something wrong when I make tabBarController indicate to multiple navigationController by storyboard.)
According to Apple for Status bar, status bar is Transparent.(I think* always, not sure). Here is the link. https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/Bars.html
Although I found the solution this a few month ago,it took a time to align the point.
checking my viewController structure causing problem , It found Black of the statusBar is self.window.backgroundColor.
so this mean status bar and navigationController was originally succeeded to be transparent, my viewController is aligned (20, 0). this was root of this problem.
and I found that this problem derived from applying contentInsets setting.
this setting affects to even view.subviews[0] too.
this happen when under some condition
•uiViewController’s view displayed via UInavigationController
•edgesForExtendedLayout is active
•view’s first element is kind of UIScrollView or these subclass
(from japanese bulletin board)
to solute this , I made originally navigationController on the storyBoard to separate from these inset setting then I explicitly set its origin to (0,0)
and I set automaticallyAdjustsScrollViewInsets = NO on my viewController.
after that, finally I could set viewController’s origin to (0,0), and I made navigationBar’s back being statusBar’s back.
below link contains so much useful information.
iOS 7 status bar back to iOS 6 default style in iPhone app?
I've tried all the solutions I can find including those in: setStatusBarHidden is deprecated in iOS 9.0 but none of them work with my application.
It is a simple, single view application. There is a Navigation bar with a single button on it which the status bar should show on top of.
In my .plist:
Status bar is initially hidden: NO
Status bar style: UIStatusBarStyleLightContent
View Controller based status bar appearance: NO
Changing any of these doesn't seem to make any difference at all. I have the status bar style "Hide during application launch" option checked as I don't want it to appear on the splash screen.
I have:
- (BOOL)prefersStatusBarHidden
{
return NO;
}
-(UIStatusBarStyle)preferredStatusBarStyle
{
NSLog(#"style");
return UIStatusBarStyleLightContent;
}
and setNeedsStatusBarAppearanceUpdate which are definitely all called when the view loads in my ViewController.
The view is established in a .storyboard, but many of the fields are manipulated in the ViewController.m as well. The value assigned to the status bar in the simulated metrics doesn't seem to have any effect either.
I need my status bar to be hidden during the launch screen and visible on the viewController. Please help me find a solution that doesn't use the deprecated setStatusbarHidden!
EDIT:
I still haven't solved this, and I surely can't be the only one with this problem! It happens in both apps that I have written.
I've just been trying to solve the same problem, I don't know why the setStatusBarHidden and setStatusBarStyle have been deprecated as the new methods are not at all intuitive.
To hide the status bar on launch I have these settings in my plist:
View controller-based status bar appearance: YES
Status bar is initially hidden: YES
Then to show the status bar after launch I have in my view controller:
- (BOOL)prefersStatusBarHidden {
return NO;
}
-(UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
This still didn't work until I found this answer https://stackoverflow.com/a/19365160/488611. So in viewDidLoad I also set the navigation bar style:
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Which makes absolutely no sense, but works.
you can use
application.statusBarHidden=YES;
in AppDelegate.m
didFinishLaunchingWithOptions
In my mind, you should change the value of UIViewControllerBasedStatusBarAppearance.
Set the value file .plist of project a is
UIViewControllerBasedStatusBarAppearance = NO
and check in file AppDelegate and set the code
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Hope my solution can be solved your problem.
OK, I totally misunderstood your question. Here's the correct answer.
Add the below value to you 'info.plist'.
Status bar is initially hidden : YES
View Controller based status bar appearance : YES
On UIViewControllers which you want to show status bar
- (BOOL)prefersStatusBarHidden {
return NO;
}
That's all.
I am not an expert on this, but I played with these settings for some time and came to the following conclusions.
General/Deployment Info:
Status Bar Style: Default (black), Light
Hide status bar (checkbox)
Both change the status bar on the launch screen only.
Note that if you take a screen shot to create this image and the screen shot included a status bar, it will appear that the device is setting the status bar even if you have checked the Hide status bar checkbox! I was tricked by this for a while before I finally thought to look at the launch image itself, and there was a status bar in the photo, so setting Hide never seemed to work even though it really was working. I removed the status bar from the images themselves using Photoshop, and the launch status bars functioned as expected after that.
Info/Custom iOS Target Properties (these change the values in the PLIST, so you could change them in either place):
Status Bar Is Initially Hidden: Yes/No
Status Bar Style: Gray (default), Transparent Black, Opaque Black
View Controller based status bar appearance : Yes/No
If you set Status Bar Is Initially Hidden to No, then you will have the status bar on your View Controller like you wanted. If you want to hide the status bar on your View Controller, you have to set Status Bar Is Initially Hidden to Yes AND set View Controller based status bar appearance to No.
Attributes Inspector for the View Controller/Simulated Metrics
Status Bar: None, Inferred, Default, Light, Black (deprecated)
This seems to have no effect on anything except the appearance of the view controllers in the StoryBoard but NOT in the simulator.
Summary: To answer your question, under General Deployment Info, check the checkbox that says Hide Status Bar. This will hide the status bar on the launch screen. Make certain that your image for the launch screen does NOT have a picture of a status bar in it. None of the settings in the StoryBoard or in the Target seems to turn off the view controller's status bar, so it seems that it will stay on like you wanted. However, I did not test any of the programmatic settings; I think that you should not do any of those, and it will work the way you want.
I have encountered a strange behaviour when using the tab bar controller in iOS. I have such a controller with 3 tabs, as can be seen on the following image:
The following problem only occurs on a physical device, not on the simulator: When I present a view controller (modal) on top and dismiss it again, the tab bar turns fully transparent (not translucent) if and only if it was presented while the map tab was active. If the list or settings tab is active when the view controller is presented, then everything stays as it's supposed to be after dismissing that view controller again.
Has anybody encountered a similar behaviour? Is it a bug? Or am I doing something wrong?
Thank you for your help.
Is this only on iPhone 4? I have had a similar bug only on 4s. There is a fix for it if that is the issue. It's an apple bug. Try in viewDidAppear in the tab controller.
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
//Stupid fix for iPhone 4 Tab bar background becoming invisible
self.tabBar.translucent = NO;
self.tabBar.translucent = YES;
}
This worked for me to fix the background disappearing on a translucent tab bar when on iPhone 4
hi i want to solution in ios7's problem.
My classes is
AlphaViewController : UIViewController,
BetaViewController : UIViewController
when AlphaViewController will appear, Alpha's navigation bar hight is 44.0f.
looks like too. and Supported Orientation is Portrait.
then I use presentmodalViewController for BetaViewController.
BetaViewController's navigation bar will be hide in viewWillAppear.
and Supported Orientation is LandScape.
then I use popViewController function. so AlphaViewController will be appear again.
I use self.navigationController.navigationBarHidden = YES;
But suddenly Alpha's navigation bar hight is changed.
It looks like 22.0f. I don't know reason..
my english is not good.
thanks to read.
first of all presentModalViewController: is deprecated since ios6 so you may not use it for presenting an view controller.
When you present a viewController from an navigationController if you want the navigation bar to be present on AlphaViewController you dont need to hide or un hide. Since you are presenting the BetaViewController navigation bar will not appear and when you dismiss it will be visible again in AlphaViewController.
I am trying to hide/show the status bar in iOS 7 (and 6) programmatically, NOT ViewController based but method based.
For example if i press button 1 the status bar disappears, if i press button 2 the status bar appears.
I have tried all combinations here and from google, but all are viewcontroller based so far.
Does anybody have an idea how to do it, method based?
Use the UIApplication methods
- (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation
on the instance [UIApplication sharedApplication]