取消searchBar 背景颜色设置

    _searchBar.backgroundColor = [UIColor clearColor];

 _searchBar.backgroundImage = [self imageWithColor:[UIColor clearColor] size:_searchBar.bounds.size];


//取消searchbar背景色

- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size

{

 CGRect rect = CGRectMake(0, 0, size.width, size.height);

UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();


CGContextSetFillColorWithColor(context, [color CGColor]);

CGContextFillRect(context, rect);


UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

  UIGraphicsEndImageContext();

   

  return image;

}


你可能感兴趣的:(取消searchBar 背景颜色设置)