I am creating a search screen using UISearchController, in which I have to show three scope buttons.I have put search bar programmatically.But somehow the scope buttons are hiding behind the UITableView.
- (void)viewDidLoad {
[super viewDidLoad];
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.searchBar.delegate = self;
self.tblFoundList.tableHeaderView = self.searchController.searchBar;
self.definesPresentationContext = YES;
[[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setDefaultTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor]}];
[[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setAttributedPlaceholder:[[NSAttributedString alloc] initWithString:@"Search by" attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor]}]];
self.searchController.searchBar.tintColor = [UIColor purpleColor];
self.searchController.searchBar.barTintColor = [UIColor groupTableViewBackgroundColor];
self.searchController.searchBar.scopeButtonTitles = @[@"A",@"B", @"C"];
[self.searchController.searchBar sizeToFit];
}
Could anyone help in this? Thank you.