王鹏凯,空包网c1kb 点康姆,蜀山战纪第3季
今天用到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; }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
网友评论