【问题标题】:To reduce gap between tableview section in swift快速减少表格视图部分之间的差距
【发布时间】:2021-03-26 20:45:01
【问题描述】:

我想快速缩小表格视图部分之间的差距。我试过“.leastNormalMagnitude”。但是我仍然在各个部分之间获得了一些空间。我想应该没有空间。谁能帮帮我?

        func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
            return CGFloat.leastNormalMagnitude
        }

        func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
            return UIView()
        }

【问题讨论】:

    标签: swift tableview


    【解决方案1】:
    return 0
    

    而不是

    return CGFloat.leastNormalMagnitude
    

    【讨论】:

    • 当 tableview 样式为 "Plain" 时工作正常。但是对于“分组”的 tableview 样式,它不是很好。还有一些空间
    【解决方案2】:

    隐藏章节标题:

    override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        return nil
    }
    
    
    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return .zero
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-30
      • 2014-04-27
      相关资源
      最近更新 更多