0

嗨,我想显示没有任何背景颜色的表格视图,所以我使用以下代码将其清除

[uiTableView setBackgroundColor:[UIColor clearColor]];

这在新 iPad 和其他一代 iPad 中运行良好,但在 iPad 版本一中无法运行。表格以背景灰色显示。这与iOS 5有关吗?谁能告诉我我们是否可以清除第一版 iPad 中的背景颜色。

4

2 回答 2

0

我在 iOS 5+ 下也注意到了同样的事情。试试这个:

[uiTableView setBackgroundColor:[UIColor clearColor]];
[uiTableView setBackgroundView:nil];

应该按预期工作。

编辑:如果您使用默认单元格,它们会覆盖UITableView,因此更改UITableView的背景颜色和视图不会做任何事情。tableView:cellForRowAtIndexPath:在你的方法中试试这个:

cellName.backgroundColor = [UIColor clearColor];
cellName.backgroundView = nil;
于 2013-02-26T22:52:44.343 回答
0

由于 tableview 有另外一个视图作为其背景。您可以通过两种方式设置背景颜色。

i) 设置 tableview 的背景颜色并将 backgroundView 设置为 nil。

[uiTableView setBackgroundColor:[UIColor clearColor]];
[uiTableView setBackgroundView:nil];

ii) 为 tableView backgroundView 设置 backgroundColor。

UIColor *backgroundColor = [UIColor clearColor];
uiTableView.backgroundView = [[UIView alloc] initWithFrame:self.tableView.bounds];
uiTableView.backgroundView.backgroundColor = backgroundColor;
于 2013-02-26T23:35:53.903 回答