【问题标题】:How to change status bar background color如何更改状态栏背景颜色
【发布时间】:2013-11-11 05:31:14
【问题描述】:

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

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

【问题讨论】:

  • 你现在用的是哪个iOS版本?

标签: ios statusbar


【解决方案1】:
  1. UIViewControllerBasedStatusBarAppearance 设置为。打电话

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

更多详情...查看link

编辑:尝试添加这个

self.extendedLayoutIncludesOpaqueBars = YES;

【讨论】:

    【解决方案2】:

    在 iOS 7 中,状态栏是透明的。如果您设置UIStatusBarStyleLightContent,请确保背景视图为暗色

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

    【讨论】:

      【解决方案3】:

      1) 在 plist 中将UIViewControllerBasedStatusBarAppearance 设置为YES

      2) 在viewDidLoad 中做一个[self setNeedsStatusBarAppearanceUpdate]

      3) 添加如下方法:

      -(UIStatusBarStyle)preferredStatusBarStyle
      { 
           return UIStatusBarStyleLightContent; 
      } 
      

      也检查developers-guide-to-the-ios-7-status-bar

      【讨论】:

        猜你喜欢
        • 2015-09-26
        • 2019-11-20
        • 2016-10-16
        • 2012-02-21
        • 2015-10-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-11-05
        相关资源
        最近更新 更多