UISearchBar 按钮的文字和颜色更改

设置 取消 按钮的颜色 为 黑色(这个方法是google来的)

[[UIBarButtonItem appearanceWhenContainedIn: [UISearchBar class], nil] setTintColor:[UIColor blackColor]];


至于更改cancel按钮为 “取消”按钮

- (void)searchBarTextDidBeginEditing:(UISearchBar *)hsearchBar
{
    self.searchBar.showsCancelButton = NO;
    for(id searchButton in [self.searchBar subviews])
    {
        if([searchButton isKindOfClass:[UIButton class]])
        {
            [(UIButton *)searchButton setTitle:@"取消"  forState:UIControlStateNormal];
            
        }
    }
}



未完待续

 

posted on 2014-07-05 13:17  超级庄子  阅读(404)  评论(0编辑  收藏  举报

导航