1

在 iOS15 上,我不再能够设置为黑色

UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().barTintColor = UIColor(hexString: "#000000")
UINavigationBar.appearance().barStyle = UIBarStyle.black

我已经通过更改解决了这个问题

let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.backgroundColor = .black
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]

UINavigationBar.appearance().standardAppearance = appearance;
UINavigationBar.appearance().scrollEdgeAppearance = UINavigationBar.appearance().standardAppearance;

但现在我遇到了缺少电池/时钟图标的问题

iOS15 不工作

工作 iOS13

4

2 回答 2

1

更改状态栏样式info.plist

1:设置UIViewControllerBasedStatusBarAppearance为假

<key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>

2:添加状态栏样式键,设置Light Content等样式

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
于 2021-08-16T07:05:49.047 回答
1

在您的UINavigationController覆盖preferredStatusBarStyle和返回.lightContent

class MyNavigationController: UINavigationController {
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
}
于 2021-08-13T18:20:40.663 回答