我正在使用 Google map 地点选取器并想更改导航栏颜色。 我试过以下几行,但他们都在工作...... 导航栏保持白色... 非常感谢您提供的任何帮助!
let autocompleteController = GMSAutocompleteViewController()
autocompleteController.navigationController?.navigationBar.barTintColor = UIColor.blue
autocompleteController.tintColor = UIColor.blue
autocompleteController.primaryTextHighlightColor = UIColor.jnlyDarkGrey
autocompleteController.primaryTextColor = UIColor.black
autocompleteController.secondaryTextColor = UIColor.gray
autocompleteController.tableCellBackgroundColor = UIColor.white
最佳答案
我觉得有点奇怪,但这在 Swift 4 中有效:
let autocompleteController = GMSAutocompleteViewController()
UINavigationBar.appearance().tintColor = UIColor.red
我假设您的应用程序中的其他导航栏项目也会对其进行更改,因此当此 View Controller 被关闭或其他需要不同样式的加载时,您可能必须将其更改回来。
关于快速更改 GMSAutocompleteViewController 导航栏颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50021795/