James Harpe
James Harpe

Reputation: 4345

iOS: UISearchBar background issue

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?

Upvotes: 0

Views: 1931

Answers (2)

zbMax
zbMax

Reputation: 2818

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

Upvotes: 1

staticVoidMan
staticVoidMan

Reputation: 20274

try:
searchBar.searchBarStyle = UISearchBarStyleMinimal;

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

Upvotes: 0

Related Questions