今天小編跟大家分享一篇關于IOS中設置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;
}
以上就是關于IOS中設置UISearchBar背景顏色的詳細教程了,想必都了解了吧,更多相關內容請繼續關注武林技術頻道。
新聞熱點
疑難解答