iOS 开发修改 searchbar 的背景颜色
2017-04-19 15:56
375 查看
/**先取消背景颜色*/
- (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.backgroundImage = [self
imageWithColor:[UIColor
redColor] size:self.searchBar.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;
}
/**调用*/
_searchBar.backgroundImage = [self
imageWithColor:[UIColor
redColor] size:self.searchBar.bounds.size];
相关文章推荐
- IOS开发之修改UISearchBar的背景颜色
- 85.如何更改iOS上的UISearchBar组件的内部背景UITextField颜色 修改UISearchBar删除按钮ClearButton
- iOS 开发-修改 UISearchController中 searchBar 的取消按钮颜色
- 修改UISearchBar的背景颜色
- 修改searchbar的背景颜色
- iOS开发- backBarButtonItem 颜色/文字修改
- iOS开发- backBarButtonItem 颜色/文字修改
- iOS 修改searchBar cancel 按钮为取消 并修改颜色
- 修改UISearchBar的TextField的背景颜色
- ios开发之--调整UISearchBar的输入框的背景颜色
- iOS UISearchBar的背景颜色修改
- IOS开发代码分享之设置UISearchBar的背景颜色
- 修改UISearchBar背景颜色
- iOS 关于searchbar的背景颜色的设置
- IOS开发—无需自定义,修改tabbar背景颜色
- 修改searchBar两种后背景颜色
- 修改UISearchBar背景颜色
- iOS searchbar的背景颜色怎么改成透明
- 修改UISearchBar背景颜色
- iOS开发之--如何修改TabBarItem的title的字体和颜色/BarButtonItem的title的字体大小和颜色/添加背景图片,并添加点击方法