如何为iOS自定义GMSAutocompleteViewController?

问题描述 投票:1回答:2

我在ios中使用Google自动完成的placekicker。它向我展示了原生设计的控制器。我想自定义它的导航栏colour.But我无法做到。下面是代码

        let autocompleteController = GMSAutocompleteViewController()
        autocompleteController.tintColor = UIColor.red
        autocompleteController.navigationController?.navigationBar.barTintColor = Constant.AppColor.navigationColor
        autocompleteController.delegate = self
        self.present(autocompleteController, animated: true, completion: nil)

enter image description here

ios swift xcode uicolor gmsautocomplete
2个回答
1
投票

我能够在Swift中自定义一些元素,如下所示:

     // Sets the background of results - top line
    autocompleteController.primaryTextColor = UIColor.black

    // Sets the background of results - second line
    autocompleteController.secondaryTextColor = Color.black

   // Sets the text color of the text in search field
    UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.white]

0
投票

Google Place Autocomplete文件可以帮助你。

根据文件,使用UIAppearanceProtocol来定制视觉主题。

请参阅本文档中的“自定义文本和背景颜色”部分。

enter image description here

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.