无法更改状态栏的样式

时间:2015-10-13 09:54:22

标签: ios swift uinavigationbar

我的iOS应用程序中实现了一个导航栏,我将色调颜色设置为白色,但在运行应用程序时,状态栏不会跟随色调并且只是透明(参见图像)。我的目标是让状态栏具有半透明的风格。

如何解决这个问题?

enter image description here

3 个答案:

答案 0 :(得分:4)

要更改所有Viewcontrollers中的状态栏颜色,请将其添加到info.plist

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

然后清理并运行构建。

要设置特定于ViewControllers的状态栏颜色,请在info.plist

中添加以下内容
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>

在ViewController的viewDidLoad方法中调用此方法:

[self setNeedsStatusBarAppearanceUpdate];

在ViewController中添加以下方法:

- (UIStatusBarStyle)preferredStatusBarStyle
{ 
    return UIStatusBarStyleLightContent; 
}

干杯:]

答案 1 :(得分:2)

你有没试过这个?

UIApplication.sharedApplication().statusBarStyle = .LightContent

答案 2 :(得分:2)

试试这个

git branch -m develop current
git branch -m other_branch develop

检查链接add the view in status bar 检查下一步 link

相关问题