在我的应用程序中,我添加了一个UITableView
和UISearchBar
,并将其背景默认为白色。我想改变两个项目的背景以清晰或透明,为此我尝试改变背景颜色。如何为UITableView和UISearchBar创建透明背景
tableview.tintColor=[UIColor clearColor];
srchbar.tintColor=[UIColor clearColor];
但它不影响UI。如何正确地做到这一点?
下面给出的用户界面屏幕截图。
在我的应用程序中,我添加了一个UITableView
和UISearchBar
,并将其背景默认为白色。我想改变两个项目的背景以清晰或透明,为此我尝试改变背景颜色。如何为UITableView和UISearchBar创建透明背景
tableview.tintColor=[UIColor clearColor];
srchbar.tintColor=[UIColor clearColor];
但它不影响UI。如何正确地做到这一点?
下面给出的用户界面屏幕截图。
对于iOS7 +,所有你需要做的是:
[self.searchBarHome setBackgroundColor:[UIColor clearColor]];
[self.searchBarHome setBarTintColor:[UIColor clearColor]]; //this is what you want
对于TableView中
[self.yourtableView setBackgroundView:nil];
[self.yourtableView setBackgroundColor:[UIColor clearColor]];
而且ASIGN鲜明的色彩与细胞
cell.backgroundColor = [UIColor clearColor];
而对于的UISearchBar
[self.yourSearchBar setBackgroundColor:[UIColor clearColor]];
[self.yourSearchBarsetBackgroundImage:[UIImage new]];
[self.yourSearchBar setTranslucent:YES];
海...谢谢你.....通过使用我的代码我可以改变表格视图,但搜索栏没有得到改变。它的背景是白色的本身..... –
这种变化是所有搜索栏的全球手段 [ [UITextField appearanceWhenContainedIn:[UISearchBar class],nil] setBackgroundColor:[UIColor clearColor]]; –
的可能的复制[制作的UISearchBar背景清晰(http://stackoverflow.com/questions/20993092/make-uisearchbar-background-clear) – jalone