_searchShopOrGoodBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 310, 24)];
_searchShopOrGoodBar.placeholder = @"请输入商家或商品名称";
[_searchShopOrGoodBar setSearchBarStyle:UISearchBarStyleDefault];
_searchShopOrGoodBar.layer.cornerRadius=10;
UIImage* searchBarBg = [self GetImageWithColor:[UIColor clearColor] andHeight:32.0f];
[_searchShopOrGoodBar setBackgroundImage:searchBarBg];
//self.searchBar.backgroundImage= [self imageWithColor:[UIColor clearColor] size:self.searchBar.bounds.size];
//搜索条自定义样式
- (UIImage*) GetImageWithColor:(UIColor*)color andHeight:(CGFloat)height
{
CGRect r= CGRectMake(0.0f, 0.0f, 1.0f, height);
UIGraphicsBeginImageContext(r.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, r);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}