gpt4 book ai didi

iOS Swift 3 - 有没有人设法使用自定义 UI 实现 Google Place API 的新 GMSPlacePickerViewController?

转载 作者:搜寻专家 更新时间:2023-10-31 19:32:44 25 4
gpt4 key购买 nike

我目前正在重新构建一个应用程序,该应用程序使用来自 Google Place API 的 PlacePicker 来获取用户随后可以添加到我的 map 上的数据。

过去,我使用的是 GMSPlacePicker,自从 Google 发布其 Place API 2.3 以来,该工具现已弃用。因此,我目前正在尝试通过 GMSPlacePickerViewController 迁移到他们使用 API 的新方式,根据 Google 的说法,可以使用自定义 UI 实现。

来自谷歌的documentation :

As the place picker is a normal view controller it can be displayed any way you want. For example, in a popover, fullscreen, pushed onto a navigation stack, or even as part of a custom app UI.

我已经设法使 GMSPlacePickerViewController 成为我更广泛的导航 Controller 的一部分,它让我可以在地点选择器的屏幕内来回移动,但是我还没有设法自定义我们在第三个屏幕上看到的搜索栏的 UI屏幕如下图。

问题:

SearchBar 内的文本是黑色的,我想把它变成白色,但我不知道如何访问 searchBar 及其属性,因为框架中的一切似乎都是抽象的。我还想将标题“选择位置”(屏幕 2)更改为更小的内容。

有什么想法吗?提前致谢

enter image description here

最佳答案

您应该能够使用 UIAppearance 代理更改此设置,如 Use the UIAppearance Protocol 中所述(GMSPlacePickerViewController 在内部使用 GMSAutocompleteViewController)。

// Color of typed text in the search bar.
NSDictionary *searchBarTextAttributes = @{
NSForegroundColorAttributeName: lightGray,
NSFontAttributeName : [UIFont systemFontOfSize:[UIFont systemFontSize]]
};
[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]]
.defaultTextAttributes = searchBarTextAttributes;

关于iOS Swift 3 - 有没有人设法使用自定义 UI 实现 Google Place API 的新 GMSPlacePickerViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44800207/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com