当我搜索 UISearchBar
时,我的正常tableView
已设置为
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
CustomCell *cell=(CustomCell *)[FieldTableView dequeueReusableCellWithIdentifier:@"Cell"];
//set cell background color cleare color
cell.backgroundColor=[UIColor clearColor];
if (isSearching) {
cell.AddPFFieldLable.text = [filteredContentList objectAtIndex:indexPath.row];
} else {
cell.AddPFFieldLable.text=[[fieldArray objectAtIndex:indexPath.row]valueForKey:@"FName"];
}
但当我搜索任何内容时,它会显示如下
如何将背景颜色更改为 clearColor
答案 0 :(得分:1)
好的,我得到了我的查询答案
[self.searchDisplayController.searchResultsTableView setBackgroundColor:[UIColor clearColor]];
我viewDidLoad
中唯一缺少的东西。
答案 1 :(得分:0)
我在UISearchBar中使用了这段代码。根据您的要求使用
-(void)addSearchController {
// No search results controller to display the search results in the current view
[[UIBarButtonItem appearanceWhenContainedIn: [UISearchBar class], nil] setTintColor:CODE_2_COLOR];
self.searchDisplayController.searchBar.placeholder = @"Search your connection list";
UITextField *txfSearchField = [self.searchDisplayController.searchBar valueForKey:@"_searchField"];
txfSearchField.backgroundColor = CODE_6_COLOR;
self.searchDisplayController.searchBar.barTintColor=CODE_6_COLOR;
CGRect rect = self.searchDisplayController.searchBar.frame;
UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, rect.size.height-2,rect.size.width, 2)];
lineView.backgroundColor = CODE_6_COLOR;
[self.searchDisplayController.searchBar addSubview:lineView];
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setDefaultTextAttributes:@{
NSFontAttributeName: [FontManager getRobotoMediumFontWithSize:14],
}];
self.tableView.tableHeaderView = self.searchDisplayController.searchBar;
}