2014-07-18 50 views
1

UISearchbar視圖有一個默認灰色區域。向下滾動時,我們可以看到灰色區域。我需要爲灰色區域設置backgroundColor設置搜索欄範圍的背景顏色

我已經加入到UISearchBarUITableView。並且在UITableView中有刷新控制。現在的問題是,當我拉下刷新控件時,看起來很奇怪。因爲刷新控制發生背景表視圖(白色)的搜索視圖採用默認backgroundColor(灰色)

如果我爲UISearchbar設置backgroundColor它只適用於UISearchBar而不是UISearchBar的範圍。有了這個結果,我正在考慮灰色區域是否屬於哪個視圖。我相信沒有額外的觀點。我已將顏色設置爲tableviewrefresh view,UISearchBarself.view,但注意適用於灰色區域。

謝謝,

+0

[SearchItem setBackgroundColor:的UIColor redColor]]; –

+0

@KiritModi,正如我所提到的,如果我爲搜索欄設置背景,它僅適用於視圖範圍。 – selva

+0

@All,下面的行解決了我的問題,但不知道如何:) [tableview setBackgroundView:[UIImageView new]]; – selva

回答

0

添加viewsearchbar的內部,其中的灰色區域放置。將它命名爲searchBarView或者你喜歡的東西。

self.scrollView.searchBarView.backgroundColor = [UIColor yourcolor]; 

應該做的伎倆

+0

感謝您的回覆!我沒有添加任何滾動視圖,滾動我的意思是默認tableview滾動。 – selva

+0

在裏面添加另一個視圖,並動態地將它放置在CGRect中,或者通過故事板靜態放置它並執行上述操作。 如果它解決了你的問題,請在答案旁邊打勾:) 謝謝 –

0
searchbar = [[UISearchBar alloc]initWithFrame:CGRectMake(27, -5, 143, 44)]; 
     searchbar.tag = indexPath.row+1; 
     searchbar.delegate = self; 
     searchbar.backgroundColor = [UIColor clearColor]; 
     if (IS_IOS_7) { 
      [searchbar setBarTintColor:[UIColor clearColor]]; 
     }else{ 
      [[ [searchbar subviews] objectAtIndex:0] removeFromSuperview]; 
     }