分组UITableView中的透明背景-iPhone

分组UITableView中的透明背景-iPhone,iphone,uitableview,background,transparency,Iphone,Uitableview,Background,Transparency,我想使分组的UITableView透明。我通过以下代码部分成功: UIColor *bgColor = [[UIColor alloc] initWithWhite:1 alpha:0.0]; historyTable.backgroundColor = bgColor; 不幸的是,在圆形的细胞中出现了黑色的角。如何摆脱它们 而不是使用 UIColor *bgColor = [[UIColor alloc] initWithWhite:1 alpha:0.0]; historyTable.b

我想使分组的UITableView透明。我通过以下代码部分成功:

UIColor *bgColor = [[UIColor alloc] initWithWhite:1 alpha:0.0];
historyTable.backgroundColor = bgColor;
不幸的是,在圆形的细胞中出现了黑色的角。如何摆脱它们

而不是使用

UIColor *bgColor = [[UIColor alloc] initWithWhite:1 alpha:0.0];
historyTable.backgroundColor = bgColor;
只需使用:

historyTable.backgroundColor = [UIColor clearColor];

这也会清除您创建的内存泄漏。

删除UITableView backgroundView

xxx.backgroundView = nil;
这在iPad版本中是必要的。当编译为在iPad和iPhone上运行时,请检查tableView是否使用

if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) {
    [self.tableView setBackgroundView:nil];
}

我有这个问题,发现使用以下两种方法没有区别:

[[UIColor alloc] initWithWhite:1 alpha:0.0];
并使用:

[UIColor clearColor];
我尝试了这两种方法,但我的桌面视图上仍然有黑色的小角落

我还试着按照建议将backgroundView设置为零,但这也不起作用

我通过在cellForRowAtIndexPath方法中将单个单元格的背景设置为透明来解决此问题:

cell.backgroundColor =  [UIColor clearColor];

当然,这有一个副作用,就是你的细胞本身是透明的,这对每个人都不理想,但在这种情况下对我来说没关系。

对我来说,在将两者都设置为nil/clear后,它最终起作用了:

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

非常感谢你。顺便说一句,我稍后会发布bgColor,但感谢您的关注;)。不错。。正是我今天需要的注意:[UIColor clearColor]当前必须在代码中设置,如果在Interface Builder中设置clearColor,则无法工作。我不知道这一点;我从不使用IB。如果是这样的话,提交错误报告可能是值得的。顺便说一句,
[uicolorWithWhite:0 alpha:0]
也可以工作,因为这才是
[UIColor clearColor]
真正等同的。由于一些疏忽,alpha为0但RGB值不同的颜色不相等。setBackgroundView:可从iOS 3.2获得,但不固定在iPad上,不是吗?为什么要使用此检查?在将背景视图设置为零后,无需将背景颜色设置为“清除”。在我的情况下,我必须这样做,否则我将以白色背景结束。但这可能是一种特殊情况。