当前位置: 移动技术网 > 移动技术>移动开发>IOS > iOS searchbar的背景颜色怎么改成透明

iOS searchbar的背景颜色怎么改成透明

2018年03月26日  | 移动技术网移动技术  | 我要评论

iOS searchbar的背景颜色怎么改成透明。

//搜索条的背景色

self.search.backgroundImage = [self imageWithColor:[UIColor colorWithRed:237/255.0 green:237/255.0 blue:237/255.0 alpha:0] size:_search.bounds.size];

- (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;

}

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网