如何更改状态栏背景颜色

时间:2013-11-11 05:31:14

标签: ios statusbar

有没有办法改变状态栏的背景颜色现在它显示白色与电池的黑色图标我想这里的颜色是黑色是我在viewDidLoad中使用的代码

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

3 个答案:

答案 0 :(得分:0)

  1. UIViewControllerBasedStatusBarAppearance设为。呼叫

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

  3. 有关详细信息,请查看此link

    编辑:尝试添加此

    self.extendedLayoutIncludesOpaqueBars = YES;
    

答案 1 :(得分:0)

在iOS 7中,状态栏是透明的。如果要设置UIStatusBarStyleLightContent

,请确保背景视图为暗

了解更多信息您可以查看Apple UITransition Guide

答案 2 :(得分:0)

1)在plist

中将UIViewControllerBasedStatusBarAppearance设置为 YES

2)在viewDidLoad中执行[self setNeedsStatusBarAppearanceUpdate];

3)添加以下方法:

-(UIStatusBarStyle)preferredStatusBarStyle
{ 
     return UIStatusBarStyleLightContent; 
} 

还要检查developers-guide-to-the-ios-7-status-bar