UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _searchBar.size.width, _searchBar.size.height)];
[backView setBackgroundColor:[UIColor colorWithRed:248/255.0 green:248/255.0 blue:248/255.0 alpha:1]];
[_searchBar insertSubview:backView atIndex:1];
原文地址:http://blog.csdn.net/mingios/article/details/40819637