For some time I tried to remove the harmful line above my UISearchBar. It seems dark against a light background or a light dark background:


I reviewed this question , but it had nothing to do with a separator or pull-to-refresh. When I finally decided to refuse and ask for help, I started picking my tongue again and found a dazzlingly simple (although perhaps not quite intuitive) solution, so I decided to share it if others encounter the same problem. I configure the search bar as follows:
// I tried this drawing method [self.searchBar setBackgroundImage:[[UIImage imageNamed:@"linen_bg_bar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]]; // and this one. [self.searchBar setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"linen_bg_bar.png"]]]; // Same problem either way. [self.searchBar setPlaceholder:NSLocalizedString(@"Filter", @"placeholder text in the search bar")]; [self.searchBar setSearchFieldBackgroundImage:[[UIImage imageNamed:@"linen_textfield_search.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(16, 16, 16, 16)] forState:UIControlStateNormal]; [self.searchBar setImage:[UIImage imageNamed:@"linen_icon_search.png"] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal]; self.table.tableHeaderView = self.searchBar; [self.table setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"linen_bg_dark.png"]]];
In the expression of this post, I tried to draw on top of it, but it seemed that the drawing was still displayed below the line.
CGRect rect = self.searchBar.frame; UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, 2)]; lineView.backgroundColor = [UIColor redColor];
See an example with my red hiding line:

source share