Vladislav Kovalyov
Vladislav Kovalyov

Reputation: 803

iOS 7 UISearchBar customization when it is first responder

I'm trying add background image on my search bar when it going to navigation bar. But if I'm writing something like this:

self.searchDisplayController.searchBar.barTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"searchBarBG2.png"]];

there is always black color and it look bad at status bar: enter image description here

The size of my image is 320:64

Upvotes: 0

Views: 180

Answers (2)

Dimitris Bouzikas
Dimitris Bouzikas

Reputation: 4530

Try this:

searchBar.backgroundColor = [UIColor clearColor];
searchBar.backgroundImage = [UIImage imageNamed:@ searchBarBG2.png"];

Upvotes: 0

Sandeep Agrawal
Sandeep Agrawal

Reputation: 425

For iOS7, try doing

self.searchDisplayController.searchBar.searchBarStyle = UISearchBarStyleMinimal;

[self.searchDisplayController.searchBar setBackgroundImage:[self imageWithColor:[UIColor yourColor]] forBarPosition:0 barMetrics:UIBarMetricsDefault];

Upvotes: 2

Related Questions