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

[selfsetNeedsStatusBarAppearanceUpdate];

1, hidden

StatusBar does not use the following interface hide in iOS7:

[[UIApplicationsharedApplication]setStatusBarHidden:YES];

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

– (BOOL)prefersStatusBarHidden

{

returnYES;

}

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

{

returnUIStatusBarStyleDefault;

}

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.text=@”RSSI:”;

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:

XYCustomStatusBar.h

#import

@interfaceXYCustomStatusBar : UIWindow{

UILabel*_messageLabel;

}

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

– (void)hide;

@end

XYCustomStatusBar.m

#import “XYCustomStatusBar.h”

@implementationXYCustomStatusBar

– (void)dealloc{

[superdealloc];

[_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];

[_messageLabelsetTextColor:[UIColorwhiteColor]];

[_messageLabelsetTextAlignment:NSTextAlignmentRight];

[_messageLabelsetBackgroundColor:[UIColorclearColor]];

[selfaddSubview:_messageLabel];

}

returnself;

}

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

self.hidden=NO;

The self. The alpha = 1.0 f;

_messageLabel.text=@””;

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 };

}completion:^(BOOLfinished){

_messageLabel.text= message;

}];

}

– (void)hide{

The self. The alpha = 1.0 f;

[UIView animateWithDuration: 0.5 fanimations: ^ {

The self. The alpha = 0.0 f;

}completion:^(BOOLfinished){

_messageLabel.text=@””;

self.hidden=YES;

}];

}

@end

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.