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

UITableView separatorStyle=无vs.separatorColor=.清除

  •  2
  • Noodledew  · 技术社区  · 7 年前

    tableView.separatorColor = .clear tableView.separatorStyle = .none .

    现在我想知道这是否有原因。。结果是否有任何不同,或者更改样式属性是否会因为缺少0.5p而以某种方式破坏约束?

    1 回复  |  直到 7 年前
        1
  •  2
  •   Ankit Jayaswal    7 年前

    是的,你的想法是对的。

    tableView.separatorColor = .clear

    tableView.separatorStyle = .none UITableCell

    案例研究:

    UITableViewCell 设置为50。

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 50
    }
    

    如果有 UILabel 在里面 UITableViewCell 你提供了 前导、尾随、顶部和底部 那么约束 tableView.separatorStyle=.none 不会因为高度 将自动增加。

    但如果你已经申请了 高度约束 0.5像素

    它不一定每次都发生,但要防止这种情况,我们应该使用 .