修改searchBar的返回按钮的显示文字
Posted 蓝色的风1203
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了修改searchBar的返回按钮的显示文字相关的知识,希望对你有一定的参考价值。
#pragma mark 搜索框的代理方法,搜索输入框获得焦点(聚焦)
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
[searchBar setShowsCancelButton:YES animated:YES];
for(id cc in [searchBar.subviews[0] subviews])
{
if([cc isKindOfClass:[UIButton class]])
{
UIButton *cancelButton = (UIButton *)cc;
[cancelButton setTitle:@"取消" forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
// 修改文字颜色
[cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
// 修改按钮背景
[cancelButton setBackgroundImage:[UIImage resizedImage:@
"login_btn_login.png"
] forState:UIControlStateNormal];
[cancelButton setBackgroundImage:nil forState:UIControlStateHighlighted];
}
}
}
以上是关于修改searchBar的返回按钮的显示文字的主要内容,如果未能解决你的问题,请参考以下文章