快速更改 GMSAutocompleteViewController 导航栏颜色

标签 swift colors maps navbar

我正在使用 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/

相关文章:

乘法继承 inits 和 deinits 的 Swift 最佳实践?

更改背景颜色会使程序出错? (诅咒)

r - 缺失数据的区域从 geom_sf/ggplot2 map 中删除。为什么?

c++ - 映射参数 C++

ios - 将 UIPickerView 视为组合/选择框

ios - 即使从 Storyboard 链接,UICollectionView 自定义单元格的 subview 为零

swift - 转到特定的 UIViewController

CSS 叠加与外观相同的其他颜色

带有十六进制颜色的 R 散点图

android map v2 gms 在 onInfoWindowClick 中启动 Intent