代码之家  ›  专栏  ›  技术社区  ›  karim

组表单元格的透明背景

  •  1
  • karim  · 技术社区  · 13 年前

    对于组表单元,我陷入了这个问题。

    cell.backgroundColor=[UIColor clearColor]
    

    将手机背景设为黑色。它适用于普通单元格,而不适用于分组表单元格。 我想添加一些按钮,例如,带有透明背景的iPhone联系人的详细视图。

    4 回复  |  直到 7 年前
        1
  •  3
  •   karim    13 年前

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

    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;
    

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

        2
  •  0
  •   Morothar    13 年前

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

        3
  •  0
  •   Community Egal    7 年前

    我从这个答案中找到了解决方案 here 通过设置单元格背景视图

    cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
    
        4
  •  0
  •   Arunabh Das    11 年前

    我会把查尔斯的回答再往前一步,然后做下面的事情

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