组表单元格的透明背景

问题描述:

对于组表格单元格,我陷入了这个问题。组表单元格的透明背景

cell.backgroundColor=[UIColor clearColor] 

使单元格bg变黑。它适用于正常细胞,不适用于组表格细胞。 我想添加一些按钮,例如就像iPhone与透明背景的详细视图一样。

+0

你好,你说的“组的意思“?你能发表一些什么不起作用的代码吗? – Vinzius 2010-10-01 15:20:10

+0

表格样式是UITableViewStyleGrouped。代码有点复杂。在主表中,我在每个部分都使用了一些自定义单元格。我正在添加照片,您可以按照按钮之间的白色条纹。它不透明。 – karim 2010-10-04 10:53:23

如果有人遇到问题,我得到一个解决方案,设置一个透明视图作为单元格的背景视图。然后它变得完全透明。然后您可以添加更多视图或自定义单元格。

UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; 
      backView.backgroundColor = [UIColor clearColor]; 
      messageCell.backgroundView = backView; 

      messageCell.contentView.layer.cornerRadius = 10.0; 
      messageCell.contentView.layer.borderWidth = 1.0f; 
      messageCell.contentView.layer.borderColor = [[Settings getInstance] colorFrameBorder].CGColor; 
      messageCell.selectionStyle = UITableViewCellSelectionStyleNone; 
      return messageCell; 

这个解决方案被引用在*问题之一,我不记得了。 我也发现,它很容易在表头或页脚中添加透明视图。按下联系人详细信息的按钮可能会添加到页脚视图中。

从它的外观我会说你正在为你的细胞设置背景图像。您可以在右侧的每个单元格中看到它,从视图背景中有条纹。 删除单元格的背景,你应该没问题。

我发现从这个答案here解决方案通过设置单元格的backgroundView

cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; 

我会采取查尔斯的答案又进了一步,然后执行以下

self.myTableView.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];