前言
記錄下常用的屬性看峻,方便查閱
正文
- 設(shè)置取消按鈕文本
if (IOS9) {
[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[BESearchUserByNameVC class]]] setTitle:BluedLocalizedStringWithKey(@"gjp_cancel")];
} else {
[[UIBarButtonItem appearanceWhenContainedIn: [BESearchUserByNameVC class], nil] setTitle:BluedLocalizedStringWithKey(@"gjp_cancel")];
}
- 設(shè)置取消按鈕顏色
searchBar.tintColor = [UIColor gjw_colorWithHex:0x616aff];
- 設(shè)置搜索框的背景孝情,不是整個(gè)searchBar的背景
[searchBar setSearchFieldBackgroundImage:[UIImage imageNamed:@"common_searchBar_bg"] forState:UIControlStateNormal];
- 替換系統(tǒng)的搜索圖標(biāo)
[searchBar setImage:[UIImage imageNamed:@"common_searchBar_icon"] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];
- 設(shè)置整個(gè)searchBar的背景
searchBar.backgroundImage = [UIImage gjw_imageWithColor:[UIColor gjw_colorWithHex:0xf4f4f4] size:self.searchController.searchBar.bounds.size];
- 獲取搜索框的placeHoder乞旦,修改字體哲思,顏色等
UITextField *searchField = [searchBar valueForKey:@"_searchField"];
[searchField setValue:[UIColor gjw_colorWithHex:0x848bff] forKeyPath:@"_placeholderLabel.textColor"];
[searchField setValue:TEXT_FONT(14) forKeyPath:@"_placeholderLabel.font"];
- 顯式設(shè)置尺寸卦溢。在iOS8民逼,iPhone4上使用
UISearchController
的默認(rèn)searchBar
作為UITableView
的tableHeaderView
時(shí)泵殴,無法顯示,估計(jì)是個(gè)系統(tǒng)bug
searchBar.frame = CGRectMake(0, 0, SCREEN_WIDTH, 44);
效果圖
上一篇:去除編譯警告
下一篇:git筆記