【发布时间】:2021-11-16 16:45:33
【问题描述】:
我有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]
}
【问题讨论】:
标签: swift uikit uinavigationbar ios15 uinavigationbarappearance