代码之家  ›  专栏  ›  技术社区  ›  Annabelle Sykes

静态表视图单元格:清除颜色不对应

  •  0
  • Annabelle Sykes  · 技术社区  · 7 年前

    我有下面的控制器和单元格的、内容视图的和表视图的 backgroundColor 设置为 .clear 但是,仍然有一个白色的背景,我不知道它对应的是什么。

    enter image description here

    3 回复  |  直到 7 年前
        1
  •  0
  •   Farkhad Gojazadeh    7 年前

    我建议您在xcode中调试它。要执行此操作,您可以在设备(或模拟器)上启动它,单击“调试视图层次结构”按钮。

    然后,通过鼠标点击+拖动屏幕矩形,您可以旋转屏幕的所有层,看看是哪个视图造成了白色背景。

        2
  •  1
  •   KK_PD    7 年前

    这是由于您的表视图单元格颜色。

    选择表视图单元格:

    enter image description here

    将其背景色设置为清晰。

    enter image description here

        3
  •  0
  •   junaid    7 年前

    此白色背景是由于表视图单元格选择表视图单元格,并从导航器中清除其背景。或者你可以进去

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "YourCellIdentifier", for: indexPath) as! YourCellClass
        cell.backgroundColor = .clear
    }
    

    image here

    这会解决你的问题… :)