Chisx
Chisx

Reputation: 1986

Can't set search bar with search bar display color iOS7

I have a "search bar and search display controller" UIObject added to a UITableViewController. The UITableViewController itself lies in an embed-linked container view. I am trying to set the color of the "search bar and search display controller" using this code in my UITableViewController.m's viewDidLoad: method, however it is not working.. what am I doing wrong?

self.searchDisplayController.searchBar.barTintColor = [UIColor darkGrayColor];
self.inviteTableSearchBar.searchBarStyle = [UIColor colorWithHexString:@"#333333"];

PS ~ The reason for the two lines is just because I'm trying different things(and these are the only things I could come up with) Also, I've already searched all throughout stack for this question and I'm pretty sure it does not exist.

Upvotes: 0

Views: 602

Answers (1)

Chisx
Chisx

Reputation: 1986

Solution Found:

I used this method to reset/recreate the background:

[self.inviteTableSearchBar setBackgroundImage:[UIImage new]];

Then simply reset my background UIColor using:

self.inviteTableSearchBar.backgroundColor = [UIColor colorWithHexString:@"#333333"];

No need to re-instantiate yourUISearchBar's subclass.

Upvotes: 1

Related Questions