如何更改iPhone应用程序中状态栏的颜色?

Tre*_*ood 1 uikit ios swift

如何更改iPhone应用程序中标题部分(状态栏)的颜色.带有载体,时间和电池的部分.

这部分

在此输入图像描述

更具体地说,这部分.我想将UI从黑色,白色或更容易看到的颜色更改.

在此输入图像描述

Ras*_*n L 6

要更改导航栏颜色:

navigationController!.navigationBar.barTintColor = UIColor.blueColor()
Run Code Online (Sandbox Code Playgroud)

要更改导航栏中的文本:

navigationController!.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.yellowColor()]
Run Code Online (Sandbox Code Playgroud)

更新
要更改状态栏:

  1. 转到info.plist并添加以下密钥View controller-based status bar appearance并将值设置为NO
  2. 在你的viewControllers中,viewDidload做了设置

白条:
UIApplication.sharedApplication().statusBarStyle = .LightContent

暗条:
UIApplication.sharedApplication().statusBarStyle = .Default