【问题标题】:UIStatusBar in iOS7 change coloriOS 7 中的 UI 状态栏更改颜色
【发布时间】:2014-03-07 05:16:24
【问题描述】:

我正在使用UINavigationController

对于rootViewController,我将导航栏设置为透明

[self.view setBackgroundColor:[UIColor greenColor]];
self.navigationController.navigationBar.shadowImage = [UIImage new];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

问题是,当我导航到第二个 viewController

[self.navigationController.navigationBar setBackgroundColor:[UIColor greenColor]];

这里我将navigationBar颜色设置回绿色,但是状态栏没有出现在绿色背景中。

是否可以将状态栏背景改为绿色?

【问题讨论】:

    标签: ios ios7 background uinavigationbar uistatusbar


    【解决方案1】:
    [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)];
    

    也试试这个link

    【讨论】:

      【解决方案2】:

      写在 AppDelegate 的 didFinishLaunchingWithOptions 方法中

      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      {
          // Override point for customization after application launch.
      
          // Override point for customization after application launch.
          if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
              UIView *addStatusBar = [[UIView alloc] init];
              addStatusBar.frame = CGRectMake(0, 0, 320, 20);
              //change this to match your navigation bar or view color or tool bar
              //You can also use addStatusBar.backgroundColor = [UIColor BlueColor]; or any other color
              addStatusBar.backgroundColor = [UIColor colorWithRed:0.973.0/255. green:0.973.0/255. blue:0.973.0/255. alpha:1];
              [self.window.rootViewController.view addSubview:addStatusBar];
          }
          return YES;
      }
      

      并在设置状态栏背景颜色的地方编写以下代码。首先创建 appdelegate 对象并使用它调用。

      appdelegate.addStatusBar.backgroundColor = [UIColor colorWithRed:85.0/255.0 green:85.0/255.0 blue:85.0/255.0 alpha:1];
      

      Refer this:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-10-04
        • 2016-11-04
        • 2018-08-27
        • 1970-01-01
        • 1970-01-01
        • 2021-08-03
        • 1970-01-01
        • 2020-02-04
        相关资源
        最近更新 更多