I want to change color of No Results in search controller. I can change the search table background color separate indexcolor.
1 Answer
try like this,
create a property
@property (nonatomic, strong) UISearchController * searchController; then add following:
// When the user types in the search bar, this method gets called. - (void)updateSearchResultsForSearchController:(UISearchController *)aSearchController { //// .. do whatever your search results.. for (UIView *subview in ((UITableViewController *)self.searchController.searchResultsController).tableView.subviews) { if ([subview isKindOfClass:[UILabel class]]) { if ([((UILabel *)subview).text isEqualToString:@"No Results"]) { ((UILabel *)subview).textColor = [UIColor redColor]; } } } } Edited Ans:
for (UIView *subview in self.searchDisplayController.searchResultsTableView.subviews) { if ([subview isKindOfClass:[UILabel class]]) { if ([((UILabel *)subview).text isEqualToString:@"No Results"]) { ((UILabel *)subview).textColor = [UIColor redColor]; } } } 4 Comments
Antony Raphel
how you implemented UISearchController? Is it like this
[[UISearchController alloc] initWithSearchResultsController:searchResultsController]?shirish
I use it like" self.searchDisplayController.searchResultsTableView"
Antony Raphel
Updated ans, check it n let me know
Antony Raphel
you are welcome, accept the ans and vote it if you want to support me :)