gpt4 book ai didi

ios - 如何更改显示在 UISearchBar +iPhone 中的取消按钮的默认文本

转载 作者:IT王子 更新时间:2023-10-29 07:53:12 24 4
gpt4 key购买 nike

我正在开发一个应用程序,我想在其中更改搜索栏中搜索字符串的文本。我想更改出现在 SearchBar 旁边的 Cancel Button Also 的文本。在搜索栏中输入任何字符串之前,我们将获得搜索字符串作为默认字符串。我想更改该字符串的文本,当我们单击该搜索栏时,我们会在搜索栏旁边看到一个取消按钮,我想更改该取消按钮的文本。

最佳答案

使用外观代理:

id barButtonAppearanceInSearchBar = [UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil];

[barButtonAppearanceInSearchBar setBackgroundImage:grayBackgroundImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[barButtonAppearanceInSearchBar setTitleTextAttributes:@{
NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-CondensedBold" size:20],
NSForegroundColorAttributeName : [UIColor blackColor]
} forState:UIControlStateNormal];
[barButtonAppearanceInSearchBar setTitle:@"X"];

关于ios - 如何更改显示在 UISearchBar +iPhone 中的取消按钮的默认文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2536151/

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