【问题标题】:iOS 13 window background coloriOS 13 窗口背景颜色
【发布时间】:2019-08-29 14:00:34
【问题描述】:

上图处于深色模式,在应用委托中进行了以下设置:

if (@available(iOS 13.0, *)) {
    self.window.backgroundColor = [UIColor systemBackgroundColor];
}

问题是在深色模式下,顶部的白色应该是黑色的。
我怎样才能做到这一点?

谢谢。

【问题讨论】:

  • 在 iOS 13 中,窗口属于场景委托,而不是应用委托。
  • @matt 有趣.. 虽然在应用程序委托中我确实有一个有效的窗口对象:<UIWindow: 0x7fe94dd08160; frame = (0 0; 375 812); hidden = YES; tintColor = UIExtendedSRGBColorSpace 0.01 0.5 0.401961 1; gestureRecognizers = <NSArray: 0x60000273a2e0>; layer = <UIWindowLayer: 0x60000297ba40>> 我想知道为什么它说hidden.. 视图层次结构调试器打印:<UIWindow: 0x7fe94dd08160; frame = (0 0; 375 812); autoresize = W+H; tintColor = UIExtendedSRGBColorSpace 0.0627451 0.501961 0.501961 1; gestureRecognizers = <NSArray: 0x60000273a2e0>; layer = <UIWindowLayer: 0x60000297ba40>>跨度>
  • @matt 我现在明白你的意思了..慢慢沉入其中..谢谢
  • @Zsolt 你终于找到解决方案了吗?我在这里遇到了同样的问题。

标签: ios background-color uiwindow ios13


【解决方案1】:

这仍然是问题吗?这是我的代码,它根据登录状态重定向到initialViewController。它正在工作。

if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
    appDelegate.window?.rootViewController = initialViewController
    appDelegate.window?.makeKeyAndVisible()

    if #available(iOS 13.0, *) {
         appDelegate.window?.backgroundColor = .systemBackground
    }else{
         appDelegate.window?.backgroundColor = .white // as you want
    }
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-15
    • 2020-01-26
    • 1970-01-01
    • 1970-01-01
    • 2012-02-05
    • 2013-07-04
    • 1970-01-01
    • 2010-12-03
    相关资源
    最近更新 更多