I added a search bar in the UINavigationItem using the following code:
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
[searchBar sizeToFit];
searchBar.delegate = self;
self.navigationItem.titleView = searchBar;
self.navigationItem.title = self.category.title;
[searchBar release];
but the result UI is like this:

How can I change the color of the search bar and make it the same with the background of the navigation bar?
Thanks.
For a UINavigationBar there is multiple ways to manipulate background color of it:
For a search bar tintColor is also available. But in your case I suggest to inherit form UISearchBar and provide implementation as shown below to get rid from background drawing routine totally. In this case you will get search bar on an transparent toolbar and will and you will need to manage only UINavigationBar color.