简体   繁体   English

如何更改状态栏背景色

[英]How to change status bar background color

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 有没有办法更改状态栏的背景颜色,现在它显示为白色,带有黑色的电池图标,我希望这里的颜色为黑色,这是我在viewDidLoad中使用的代码

     if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;
  1. Set UIViewControllerBasedStatusBarAppearance to NO . UIViewControllerBasedStatusBarAppearance设置为NO Call 呼叫

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

For more details...check this link 有关更多详细信息...请检查此链接

EDIT: try adding this 编辑:尝试添加此

self.extendedLayoutIncludesOpaqueBars = YES;

in iOS 7 the status Bar is transparent. 在iOS 7中,状态栏是透明的。 Make sure the background view is Dark if you are setting UIStatusBarStyleLightContent 如果要设置UIStatusBarStyleLightContent请确保背景视图为暗

For more info You can check the Apple UITransition Guide 有关更多信息,请查看Apple UITransition Guide。

1) set the UIViewControllerBasedStatusBarAppearance to YES in the plist 1)在plist中将UIViewControllerBasedStatusBarAppearance设置为YES

2) in viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate] ; 2)在viewDidLoad做一个[self setNeedsStatusBarAppearanceUpdate]

3) add the following method: 3)添加以下方法:

-(UIStatusBarStyle)preferredStatusBarStyle
{ 
     return UIStatusBarStyleLightContent; 
} 

also check developers-guide-to-the-ios-7-status-bar 还要检查开发人员指南到iOS 7状态栏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM