我有一个 UIkit
项目,我想要更改导航栏颜色和返回按钮颜色。在之前的版本上工作正常,但在 iOS 15 上不行。我在 AppDelegate
中加入了以下代码,可以更改标题颜色,但无法更改返回按钮项目颜色。如何解决?
if #available(iOS 15.0, *) {
let appearance = UINavigationBarAppearance()
let navigationBar = UINavigationBar()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
appearance.backgroundColor = .red
navigationBar.tintColor = .white
navigationBar.standardAppearance = appearance;
UINavigationBar.appearance().scrollEdgeAppearance = appearance
}else{
let navBarAppearnce = UINavigationBar.appearance()
navBarAppearnce.tintColor = .white
navBarAppearnce.barTintColor = .red
navBarAppearnce.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
}