IOS7 StatusBar is called in UIViewConroller when it needs to hide or change styles:


1, hidden

StatusBar does not use the following interface hide in iOS7:


To hide it you need to implement the following functions in UIViewController:

– (BOOL)prefersStatusBarHidden




2. Style changes

IOS 7 statusbar has two styles: white font UIStatusBarStyleDefault UIStatusBarStyleLightContent and black font.

If the change needs to be implemented in UIViewController:

– (UIStatusBarStyle)preferredStatusBarStyle




3. Customize the status bar, method 1

UIWindow* statusWindow = [[UIWindow alloc]initWithFrame:[UIApplication sharedApplication].statusBarFrame];

[statusWindows etWindowLevel:UIWindowLevelStatusBar +1];

[statusWindow setBackgroundColor:[UIColor clearColor]];

UILabel* statusLabel = [[UILabel alloc]initWithFrame:statusWindow.bounds];


statusLabel.textColor= [UIColorblueColor];

statusLabel.textAlignment= NSTextAlignmentCenter;

statusLabel.backgroundColor= [UIColorblackColor];

[statusWindow addSubview:statusLabel];

[statusWindow makeKeyAndVisible];

4. Customize the status bar, method 2

If you want to display custom messages in the status bar, you need to customize the status bar.

The code is as follows:



@interfaceXYCustomStatusBar : UIWindow{



– (void)showStatusMessage:(NSString*)message;

– (void)hide;



#import “XYCustomStatusBar.h”


– (void)dealloc{


[_messageLabelrelease], _messageLabel =nil;


– (id)init{

self= [superinit];

if(self) {

self.frame= [UIApplicationsharedApplication].statusBarFrame;

self.backgroundColor= [UIColorblackColor];

Self. WindowLevel = UIWindowLevelStatusBar + 1.0 f;

_messageLabel = [[UILabelalloc]initWithFrame:self.bounds];








– (void)showStatusMessage:(NSString*)message{


The self. The alpha = 1.0 f;


CGSize totalSize =self.frame.size;

self.frame= (CGRect){self.frame.origin,0, totalSize.height};

[UIVie wanimateWithDuration: 0.5 animations: ^ {

self.frame= (CGRect){self.frame.origin, totalSize };


_messageLabel.text= message;



– (void)hide{

The self. The alpha = 1.0 f;

[UIView animateWithDuration: 0.5 fanimations: ^ {

The self. The alpha = 0.0 f;







To make a custom status bar visible to the user, set its WindowLevel. In ios, the WindowLevel property determines the display level of UIWindow. The default Windowlevel is UIWindowLevelNormal, which is 0.0. To override the default status bar, set WindowLevel high. The rest of the code basically doesn’t explain anything; if you want special effects, you can add them yourself.