gpt4 book ai didi

google-maps - 更改 UISearchBar textColor 不起作用

转载 作者:行者123 更新时间:2023-12-04 16:25:38 25 4
gpt4 key购买 nike

我正在为自动完成小部件使用谷歌地方 API。我正在使用 swift 在 ios 9+ 中显示全屏控件。我正在添加文档中给出的完整控件。

我已经添加了文档中显示的代码。现在我想将 searchBar 文本颜色更改为 whiteColor。

所以我尝试了这个

UITextField.appearanceWhenContainedInInstancesOfClasses([UISearchBar.self]).textColor = UIColor.whiteColor()

但我没有得到想要的行为。下面是截图

**enter image description here**

这已在 Docs 中给出

https://developers.google.com/places/ios-api/autocomplete#use_a_table_data_source

但这不起作用。我需要这方面的帮助。

最佳答案

使用波纹管代码 swift 3

if #available(iOS 9.0, *) {
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSForegroundColorAttributeName: UIColor.green]
} else {
// Fallback on earlier versions
}

希望这可以帮助。

关于google-maps - 更改 UISearchBar textColor 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37763114/

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