0
votes

i can't understand how create the same black status bar of iOS 6 to iOS 7, i have found this question on SO: iOS 7 status bar back to iOS 6 default style in iPhone app?

in my app i have only landscape mode, so i use this:

Set UIViewControllerBasedStatusBarAppearance to NO in info.plist (To opt out of having view controllers adjust the status bar style so that we can set the status bar style by using the UIApplicationstatusBarStyle method.)

In AppDelegate's application:didFinishLaunchingWithOptions, call

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {

 [application setStatusBarStyle:UIStatusBarStyleLightContent];

 self.window.clipsToBounds =YES;

 self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}

return YES;

but this is the result:

enter image description here

anyone can help? or suggest me another solution?

1
Seems like, you are using navigation bar. If yes, the status bar style is depends on navigation bar. Please let me know ur thoughts, so that I will give you solution on how to fix this.Nandha
Yes i want use navigation bar and i want also uso a uitabbar that control some view with navigation bar like in the image above and some view without navigation bar...how i can do?Piero
Please refer my answer below.Nandha

1 Answers

0
votes

In some cases, the background image for a navigation bar or a search bar can extend up behind the status bar (for details, please refer following table image). If there are no bars below the status bar, the content view should use the full height of the screen.

enter image description here

According to the apple doc, the navigation background image height should be exactly 44 points. In your case you are not using any custom background image, however you need the default iOS6 status bar style. You can achieve this by using the following code,

CGRect rect = CGRectMake(0, 0, 1, 44);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,[[UIColor colorWithRed:(239/255.0) green:(238/255.0) blue:(239/255.0) alpha:1.0] CGColor]);//Please change RGB value according to ur needs.
CGContextFillRect(context, rect);
UIImage *navigationBackgroundImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[[self navigationController] navigationBar] setBackgroundImage:navigationBackgroundImage forBarMetrics:UIBarMetricsDefault]; 

Now Set UIViewControllerBasedStatusBarAppearance to NO in info.plist and n AppDelegate's application:didFinishLaunchingWithOptions, call

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
 [application setStatusBarStyle:UIStatusBarStyleLightContent];//Dark status bar background with white color text
}

Hope this helps to solve your problem. For more details, please refer apple doc.