码迷,mamicode.com
首页 > 其他好文 > 详细

修改searchBar的返回按钮的显示文字

时间:2016-04-01 14:45:42      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:

#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的返回按钮的显示文字

标签:

原文地址:http://www.cnblogs.com/zj901203/p/5344778.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!