在 rootView 我有:
navigationController?.navigationBar.prefersLargeTitles = true
并在详细视图中:
navigationItem.largeTitleDisplayMode = .never
在 AppDelegate 中:
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = .BlackNav
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
感谢您的回答!
编辑:
已解决:如果您不定义 UINavigationBar.appearance().compactAppearance,线条会消失:
UINavigationBar.appearance().standardAppearance = appearance
//UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance