UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
[searchBar sizeToFit];		
//we hide the background of the search bar
[[[searchBar subviews] objectAtIndex:0] setAlpha:0.0];
//we can still add a tint color so as the search bar buttons match our new background
searchBar.tintColor = [UIColor colorWithRed:.376f green:.386f blue:.452f alpha:1.0];
//if you put the search bar in a table view header, a one pixel line will appear when you scroll
//the table view beyond the search bar. This code line prevent the line to appear.
searchBar.clipsToBounds = YES;
//you can now add the search bar and an UIImageView on one view, or add the search bar directly
//as a table view header
self.tableView.tableHeaderView = searchBar;

//if you assigne the table footer view to a search bar, you can override the drawLayer: method
//of the search bar in a UISearchBar category file. Overriding drawLayer: instead of drawRect: seems
//to be more acceptable when you submit your app to the AppStore

#import "UISearchBar+CustomBg.h"

@implementation UISearchBar (CustomBg)

- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
	UIImage *searchBarBkg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"CustomSearchBarBackground"																			 ofType:@"png"]];	
	CGContextTranslateCTM(ctx, 0, searchBarBkg.size.height);
	CGContextScaleCTM(ctx, 1.0, -1.0);
	CGContextDrawTiledImage(ctx, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), searchBarBkg.CGImage);
	[searchBarBkg release];


A little piece of code to customize the background of your search bars in iOS.