设置搜索栏范围的背景颜色

时间:2014-07-18 08:51:02

标签: ios objective-c uitableview uisearchbar

UISearchbar视图有默认灰色区域。我们可以在向下滚动的同时看到灰色区域。我需要为灰色区域设置backgroundColor

我已将UISearchBar添加到UITableView标题中。并且UITableView中有一个刷新控件。现在的问题是,当我下拉刷新控件时,它看起来很奇怪。由于刷新控件采用表格视图的背景(白色)搜索视图采用默认的backgroundColor(灰色)

如果我为backgroundColor设置UISearchbar,则它仅适用于UISearchBar,而不适用于UISearchBar的范围。有了这个结果,我在想灰色区域是否属于哪个视图。我相信没有额外的观点。我已将颜色设置为tableviewrefresh viewUISearchBarself.view,但注意适用于灰色区域。

谢谢,

3 个答案:

答案 0 :(得分:0)

在放置灰色区域的view内添加searchbar。将其命名为searchBarView或您喜欢的内容。

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

应该做的伎俩

答案 1 :(得分: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];
        }

答案 2 :(得分:0)

对于透明 scope bar,将带Alpha的1Pixel PNG添加到范围栏。

否则即使在透明的searchBar背景下也保持白色。

btw. this png is named alpha

the transparent sprachbar and scopeBar

相关问题