我正在开发一个应用程序,我想更改搜索栏中搜索字符串的文本。我想更改搜索栏旁边显示的取消按钮的文本。在搜索栏中输入任何字符串之前,我们会将搜索字符串作为默认字符串。我想更改该字符串的文本,当我们单击该搜索栏时,我们会在搜索栏旁边看到一个取消按钮,我想更改该取消按钮的文本。
使用外观代理:
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"];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)