IOS开发代码分享之设置UISearchBar的背景颜色
更新时间:2014年09月18日 09:59:50 投稿:hebedich
在项目开发中,我们经常要用到UISearchBar,在网上看到了很多关于去除掉他背景色的方法,都已经失效了,今天来分享一个正常使用的方法,希望能帮到大家
今天用到UISearchBar,之前网上提供的方法已经不能有效的去除掉它的背景色了,修改背景色方法如下:
mySearchBar.backgroundColor = RGBACOLOR(249,249,249,1); mySearchBar.backgroundImage = [self imageWithColor:[UIColor clearColor] size:mySearchBar.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; }
相关文章
UITableViewCell在编辑状态下背景颜色的修改方法
这篇文章主要给大家介绍了关于UITableViewCell在编辑状态下背景颜色的修改方法,文中通过示例代码介绍的非常详细,对大家具有一定的参考学习价值,需要的朋友们下面跟着小编一起来学习学习吧。2017-07-07
最新评论