gpt4 book ai didi

ios - 设置状态栏颜色 - 延迟?

转载 作者:行者123 更新时间:2023-11-28 08:50:09 26 4
gpt4 key购买 nike

当我尝试在 iOS 中更改 StatusBar 的文本颜色时,总会有 1-2 秒的延迟。所以它从黑色开始,然后像我想要的那样延迟变白。

所有这些更改都在我的 ViewController 中,在 ViewDidLoad 中。

我将使用自定义 View 来获取特定颜色:

    let statusBarHeight = CGFloat(20)
let colorBGView = UIView(frame: CGRectMake(0, -statusBarHeight, self.view.bounds.width, statusBarHeight))
colorBGView.backgroundColor = UIColor.customDarkerGrey()
self.navigationController?.navigationBar.addSubview(colorBGView)

并将 barStyle 设置为黑色(使用 UINavigationController 时获得白色字体)

    self.navigationController?.navigationBar.barStyle = UIBarStyle.Black

设置值:

 View controller-based status bar appearance

在plist.info中为“YES”

但仍然存在“滞后”——所以一切都是白色的,但最多需要 2 秒。有什么想法吗?

我找不到答案问题,因为这只是关于着色,而不是延迟问题:

preferredStatusBarStyle isn't called

编辑:

好的,在创建一个包含 2 个 ViewController 和一个 NavigationController 的新项目后,当您尝试将颜色从 ViewController 更改为 ViewController 时,“延迟”是正常的。看来,功能:

override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}

被调用有一点延迟 - 当错误添加时没有任何反应:

self.setNeedsStatusBarAppearanceUpdate()

所以在我的例子中,我在 NavigationController 上全局更改了它,并且(因为它加载了我的应用程序)你无法识别“延迟”。

也许这对其他人有帮助。

最佳答案

尝试在方法 didFinishLaunchinOptions 中为 AppDelegate 中的状态栏设置颜色。由于您的状态栏颜色默认设置为其他颜色,然后您在 Controller 中将其设置为新颜色,因此它的创建延迟。

还有

设置值:

View controller-based status bar appearance

在plist.info中为“NO”

关于ios - 设置状态栏颜色 - 延迟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34444921/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com