IOS開發(fā)代碼分享之設(shè)置UISearchBar的背景顏色
更新時(shí)間:2014年09月18日 09:59:50 投稿:hebedich
在項(xiàng)目開發(fā)中,我們經(jīng)常要用到UISearchBar,在網(wǎng)上看到了很多關(guān)于去除掉他背景色的方法,都已經(jīng)失效了,今天來分享一個(gè)正常使用的方法,希望能幫到大家
今天用到UISearchBar,之前網(wǎng)上提供的方法已經(jīng)不能有效的去除掉它的背景色了,修改背景色方法如下:
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; }
相關(guān)文章
UITableViewCell在編輯狀態(tài)下背景顏色的修改方法
這篇文章主要給大家介紹了關(guān)于UITableViewCell在編輯狀態(tài)下背景顏色的修改方法,文中通過示例代碼介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面跟著小編一起來學(xué)習(xí)學(xué)習(xí)吧。2017-07-07iOS設(shè)計(jì)模式——Category簡單介紹
這篇文章主要介紹了iOS設(shè)計(jì)模式——Category簡單介紹,有興趣學(xué)習(xí)的同學(xué)可以了解一下。2016-11-11safari調(diào)試iOS app web頁面的步驟
這篇文章主要為大家詳細(xì)介紹了safari調(diào)試iOS app web頁面的步驟,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06iOS中UITextField實(shí)現(xiàn)過濾選中狀態(tài)拼音的代碼
這篇文章主要介紹了iOS中UITextField實(shí)現(xiàn)過濾選中狀態(tài)拼音的代碼,需要的朋友可以參考下2018-01-01IOS 粒子系統(tǒng) (CAEmitterLayer)實(shí)例詳解
這篇文章主要介紹了IOS 粒子系統(tǒng) (CAEmitterLayer)實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2016-09-09