看来需要在iOS 13上使用新的UINavigationBarAppearance。尝试将其添加到您的viewDidLoad中:
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = .systemRed
appearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor : UIColor.white]
navigationItem.standardAppearance = appearance
navigationItem.scrollEdgeAppearance = appearance
您可能还需要设置searchField backgroundColor:
let searchField = searchController.searchBar.searchTextField
searchField.backgroundColor = .systemBackground