快速设置状态栏的自定义颜色? [英] set custom color of status bar in swift?

查看:29
本文介绍了快速设置状态栏的自定义颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在视图控制器上,我想将状态栏的颜色设置为黑色,但我无法更改它.为此,我正在使用以下代码.

On a view controller, i want to set the color of status bar black but I am not able to change it. I am using below code for this purpose.

 func setUpUI() {
        self.navigationController?.setNavigationBarHidden(true, animated: false)
        UIApplication.shared.statusBarStyle = UIStatusBarStyle.default
    }

我还在 info.plist 中添加了值

I have also added the value in info.plist

推荐答案

你只需覆盖状态栏的返回值,像这样:

You just override the return value of the status bar, like this:

override var preferredStatusBarStyle: UIStatusBarStyle {
   return .lightContent
}

这篇关于快速设置状态栏的自定义颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆