在修改了 keyWindow
的 userInterfaceStyle 后, 使用自定义 status bar style,
UIColor 的 userInterfaceStyle 会受其影响, 有时候会拿不到正确的值
let c = UIColor { (trait) -> UIColor in
switch trait.userInterfaceStyle {
case .dark:
return .black
default:
return .white
}
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
解决办法, 根据 View 自己的 userInterfaceStyle, 获取 color, 如下:
c = c.resolvedColor(with: trait)
网友评论