gpt4 book ai didi

ios - 在 Swift 中更改搜索栏占位符文本字体

转载 作者:IT王子 更新时间:2023-10-29 05:13:35 24 4
gpt4 key购买 nike

我正在尝试更改搜索显示 Controller 中搜索栏中占位符文本的字体。我正在查看一些示例并尝试实现它们,但由于它们在 Objective-C 中,我无法找到任何可以开始工作的示例。

例如,我试过这个:

UITextField *textField = [[searchBar subviews] objectAtIndex:1]; 
[textField setFont:[UIFont fontWithName:@"Helvetica" size:40]];

但我无法通过 var textField: UITextField = UISearchBar

有什么想法吗?

最佳答案

 //SearchBar Text
let textFieldInsideUISearchBar = dashBoardSearchBar.valueForKey("searchField") as? UITextField
textFieldInsideUISearchBar?.textColor = UIColor.whiteColor()

//SearchBar Placeholder
let textFieldInsideUISearchBarLabel = textFieldInsideUISearchBar!.valueForKey("placeholderLabel") as? UILabel
textFieldInsideUISearchBarLabel?.textColor = UIColor.whiteColor()

关于ios - 在 Swift 中更改搜索栏占位符文本字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26441958/

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