How to change status bar background color

2019-06-10 01:29发布

Is there way to change the background color of status bar right now it show white with black icons of battery i want the color black here is the code i am using in viewDidLoad

     if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;

标签: ios statusbar
3条回答
Viruses.
2楼-- · 2019-06-10 01:54

1) set the UIViewControllerBasedStatusBarAppearance to YES in the plist

2) in viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];

3) add the following method:

-(UIStatusBarStyle)preferredStatusBarStyle
{ 
     return UIStatusBarStyleLightContent; 
} 

also check developers-guide-to-the-ios-7-status-bar

查看更多
霸刀☆藐视天下
3楼-- · 2019-06-10 01:56
  1. Set UIViewControllerBasedStatusBarAppearance to NO. Call

  2. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

For more details...check this link

EDIT: try adding this

self.extendedLayoutIncludesOpaqueBars = YES;
查看更多
Emotional °昔
4楼-- · 2019-06-10 02:01

in iOS 7 the status Bar is transparent. Make sure the background view is Dark if you are setting UIStatusBarStyleLightContent

For more info You can check the Apple UITransition Guide

查看更多
登录 后发表回答