title: Line Above UISearchBar
body: <p>For quite some time, I had been trying to no avail to remove a pernicious line above my UISearchBar. It appears dark on a light background or light on a dark background:</p>
  
  <p><img src="https://i.stack.imgur.com/Yupmm.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/JCImw.png" alt="enter image description here"></p>
  
  <p>I looked at <a href="https://stackoverflow.com/questions/14228010/get-rid-of-line-above-uitableview">this question</a>, but it had nothing to do with the separator or pull-to-refresh. When I finally decided to give up and ask for help, I started poking around again and found a blindingly simple (though perhaps not entirely intuitive) solution, so I thought I'd share it in case others are facing the same issue. I configure the search bar as follows:</p>
  
  <pre><code>// 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"]]];
  </code></pre>
  
  <p>Per <a href="https://stackoverflow.com/a/8229991/970132">this post's</a> suggestion, I tried drawing on top of it, but it seemed the drawing <em>still</em> got rendered below the line.</p>
  
  <pre><code>CGRect rect = self.searchBar.frame;
  UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, 2)];
  lineView.backgroundColor = [UIColor redColor];
  </code></pre>
  
  <p>See the example with my red "cover-up" line:</p>
  
  <p><img src="https://i.stack.imgur.com/BUlL0.png" alt="enter image description here"></p>