0

I'm trying to change the background color of my search bar. I want this top view to be one solid color. Here's the code I'm using:

 [titleBarView setBackgroundColor:[ColorUtil colorWithHexString:@"1ABC9C"]];
searchBar.barTintColor=[ColorUtil colorWithHexString:@"1ABC9C"];
searchBar.backgroundColor=[ColorUtil colorWithHexString:@"1ABC9C"];

And below is the result I'm getting. Notice that there's some gray along the top and bottom edges of the search bar. How do I get rid of this?

enter image description here

EDIT: After adding

 searchBar.searchBarStyle=UISearchBarStyleMinimal;

I now get this:

enter image description here

So my original issue is solved, but now the interior of the searchBar is the wrong color. What property governs that?

James Harpe
  • 4,315
  • 8
  • 47
  • 74

2 Answers2

1

What about your view hierarchy? Have you tried [searchBar setBarTintColor:[UIColor clearColor]];

zbMax
  • 2,756
  • 3
  • 21
  • 42
0

try:
searchBar.searchBarStyle = UISearchBarStyleMinimal;

ref: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISearchBar_Class/Reference.html

staticVoidMan
  • 19,275
  • 6
  • 69
  • 98
  • Please see my edit. This solved my original problem, but changes the color of the interior of the bar. – James Harpe Dec 03 '13 at 17:20
  • @JamesHarpe : _just to put it out there..._ solution to the non-white searchbar field background, here: http://stackoverflow.com/a/12598711/2857130 – staticVoidMan Dec 03 '13 at 17:45