Status bar has black background behind it - even when not visible - iphone

I have the following code:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO];
Anything I put behind the status bar, including a background color, can't be seen however. And when i do this, it just leaves a black background behind where it was:
[UIApplication sharedApplication].statusBarHidden = YES;
Any ideas why this might be happening?

Have you tried setting the status bar to hidden in the application's info.plist? Does that make a difference?

Related

How to change UIViewControllerBasedStatusBarAppearance to YES/NO programmatically in iOS 7?

My application has a dark background, but in iOS 7 the status bar became transparent. So I can't see anything there, only green battery indicator in the corner. How can I change the status bar text color to Green or Orange like it is on the home screen?
I know about
Set the UIViewControllerBasedStatusBarAppearance to YES in the plist
In viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];
Add the following method:
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
How can I change UIViewControllerBasedStatusBarAppearance programmatically?
Thanks in advance...
In Info.plist set 'View controller-based status bar appearance' as NO.
then,add this in your appdelegate.m class in didfinishlaunchingwithoptions method.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
this works for ios 7.
As mention by others add "View controller-based status bar appearance' in your application's info.plist and set it to Type: Boolean and Value: NO
For your ready reference:
In iOS 9
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
method is deprecated.
So you can use this:
application.statusBarStyle = UIStatusBarStyleLightContent;
add this line of code in method
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
which is present in appDelegate.m file. This will change the status bar text color throughout your application.
So if you have any screen which has background may be dark or light then in that screen you can the status bar color by making use of:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
Hope this helps.

"UIWindowLevelStatusBar + 1" strange keyboard behaviour

This code in the appDelegate makes my app behave strange
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.windowLevel = UIWindowLevelStatusBar + 1;
return YES;
}
When hiding the keyboard from the function [myTextView resignFirstResponder] I'm getting my keyboard disappearing under the view, not sliding down as it should.
What is the best way to change this? Why does UIWindowLevelStatusBar + 1 mess up all the app structure?
EDIT:
What I'm trying to do is create a view on top of the statusBar. Is setting UIWindowLevelStatusBar + 1 in the appDelegate a wrong way to do this?
Man, i know this is 2 year old but here it goes:
Works on iOS 7 and 8, not tested on 9 betas.
I'm adding a ticker to the status bar. Yeah i know apple does not like it, but users have the choice to use it there ore somewhere else.
In app Delegate, when you want to hide the contents of the status bar (carrier, hour, battery), you call:
self.window.windowLevel = UIWindowLevelStatusBar+1;
Ok
The problem was to figure out how to get the contents back, right ? That was my problem too. Here it is:
self.window.windowLevel = UIWindowLevelStatusBar-1;
Bye
The keyboard also exists in a window (everything on the screen does) and that window has a level lower than your window's.
Why are you setting your window level so high? If you tell us what you're trying to accomplish, we may be able to suggest an alternate approach.
Hide the status bar and set frame for navigation bar simple.
CGRect statusFrame = [UIApplication sharedApplication].statusBarFrame;
[[UIApplication sharedApplication] setStatusBarHidden:YES];
self.navigationController.navigationBar.frame = CGRectMake(0, statusFrame.size.height, 320,46);
[[AppDelegate instance].window addSubview:statusView];

UIImagePickerControllerSourceTypePhotoLibrary status bar solid/white

I'm creating an app, that is in some point turning photo library on. The problem is that status bar is black transparent in photo library while i want a default application one (solid white). Is there any way to change it..?
I would add, that i tried regarding to this: iOS SDK - How to get the status bar back when using UIImagePickerController? method:
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
}
works only for camera for me, not photo library. Of course i tried with default style too.
UPDATE: i found out a way to change navigation bar:
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
navigationController.navigationBar.barStyle = UIBarStyleDefault;
}
This one works, however status bar style is still dark, while i need the default application one, so white.
Many thanks in advance!
Fixed my problem in a different way. To keep the status bar always the same i just added viewDidAppear method, that is written in my main post to my rootViewController, so it is same all the time including turning photo library on

How to get a black status bar on an iPhone app?

I want to use a black status bar for my iPhone app. I have selected black status bar on all of my .xibs but I still can't get it to be black. Is this an issue that anyone else has seen or knows how to remedy?
Open the "info.plist" file .
Add a new row.
Select "Status bar style" as the key.
Select "Opaque black style" as the value.
EDIT: The comment by #codrut below to choose the value:
If you go far to the right, there's a button that brings you a drop down with the possible options.
The status bar in the nib files is there as an indication, just to simulate the real interface.
What you need to do is:
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];
and in the plist change the Status Bar Style (UIStatusBarStyle) to Black opaque (UIStatusBarStyleBlackOpaque) (or whatever you want).
Add the following in the info.plist file
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
Not sure if this will help anyone else, but in our app we ran into an issue where the only way we could get it to use the black style was if we set it to the default style:
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault];
Might be worth giving that a try if BlackOpaque isn't working for you.
Try this simple method....
1.For single viewController
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];
2.For whole application
info.plist
----> Status Bar Style
--->UIStatusBarStyle to UIStatusBarStyleBlackOpaque

Write some text in (or on) UIStatusBar

I know, it's a strange question ^^,
I would like to know if there is a way to write some text in (or on) the UIStatusBar. In particular I want to write some text on the Status Bar when the user press a UIButton.
Thanks!
I'm not sure if you can draw directly into the status bar, but you should be able to draw on top of it in a custom view. You can get the status bar's frame using:
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
And you can get the application's main window (presumably the status bar's superview) using:
UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];
You should be able to add your custom view directly to the key window in the status bar's frame. For an example of an app that appears to "modify" the status bar, take a look at Reeder.
No, the status bar is a system-controlled element. It's content cannot be modified by a third-party application.
Check out this work in progress: https://github.com/maciekish/APStatusBarExtensions
MTStatusBarOverlay is what you want :
https://github.com/myell0w/MTStatusBarOverlay
Definitely the easier to use !