My current application runs on iOS 5 and 6.
The navigation bar is having an orange color and the status bar is having a black background color with white text color. However, when I run the same application on iOS 7, I observe the status bar looks transparent with the same orange background color as the navigation bar and the status bar text color is black.
Due to this I'm not able to differentiate between the status bar and the navigation bar.
How do I make the status bar to look the same as it was in iOS 5 and 6, that is with black background color and white text color? How can I do this programmatically?
Just to add to Shahid's answer - you can account for orientation changes or different devices using this (iOS7+):
For bar color: You provide a custom background image for the bar.
For text color: Use the information in About Text Handling in iOS
Please try this. Use this code in your appdelegate class "didFinishLaunchingWithOptions" function
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; [application setStatusBarHidden:NO]; UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"]; if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) { statusBar.backgroundColor = [UIColor blackColor]; }
While handling the background color of status bar in iOS 7, there are 2 cases
Case 1: View with Navigation Bar
In this case use the following code in your viewDidLoad method
Case 2: View without Navigation Bar
In this case use the following code in your viewDidLoad method
Source link http://code-ios.blogspot.in/2014/08/how-to-change-background-color-of.html
Swift 4
In
Info.plist
add this propertyView controller-based status bar appearance to NO
and after that in
AppDelegate
inside thedidFinishLaunchingWithOptions
add these lines of codeWrite this in your ViewDidLoad Method:
It fixed status bar color for me and other UI misplacements also to a extent.