-1

I want to change color of No Results in search controller. I can change the search table background color separate indexcolor.

1 Answer 1

0

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]; } } } 
Sign up to request clarification or add additional context in comments.

4 Comments

how you implemented UISearchController? Is it like this [[UISearchController alloc] initWithSearchResultsController:searchResultsController]?
I use it like" self.searchDisplayController.searchResultsTableView"
Updated ans, check it n let me know
you are welcome, accept the ans and vote it if you want to support me :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.