In my application i want to set the statusbar transparent.There are three styles are possible for changing the style o开发者_运维技巧f the statusbar.
- gray
- black
- black translucent
mycode:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
How to set the transparent statusbar?
The best solution for this problem is to set self.wantsFullScreenLayout = YES;
in your view controller and [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
for your status bar.
UPDATE:
As Mihir Oza told in comments the UIStatusBarStyleBlackTranslucent
constant from old version of my answer is now deprecated. Use UIStatusBarStyleLightContent
instead.
For the global app in the info.plist
add Status bar style: Transparent Black Style (alpha 0.5)
.
The best way of doing this is with info.plist. Have a look at Apple's UIKit pList keys, specifically UIStatusBarStyle
(and the value UIStatusBarStyleBlackTranslucent
) for making it translucent, or the UIStatusBarHidden key (for hiding it totally).
It's not possible to make the status bar transparent. There are only 3 possible styles (gray, black and black translucent) you can set and you cannot get the bar's UIView.
However if you have static content behind it (i.e. a fixed part of your UI that you can edit) you can set the status bar to black translucent and add a 50% white layer just behind the bar. This makes the bar appear to be transparent.
Here's an example of what I mean.
See an example http://cl.ly/7WST/Untitled-1.png
- In the info.plist set status bar style Transparent black style (alpha of 0.5).
- In viewcontroller.xib set size fullscreen and status bar none.
- In viewcontroller.m add following codes in viewWillAppear:
self.view.frame = CGRectMake(0,0,320,480);
This worked for me.
You can only hide the status bar using Status bar is initially hidden
property in your info.plist
精彩评论