在tableview重新加载期间绘制线条的问题

时间:2018-04-25 15:24:59

标签: ios swift uitableview animation drawing

我有一个tableview。我重装了一节。我的sectionheader有一行需要绘制。 此行的位置及其绘制方式基于contentview的框架

  1. 如果tableview.reloadData()是正确绘制的话。 Tableview标题的框架为非零
  2. 如果我执行notesTable.reloadSections([1], with: .automatic),则 无法正确绘制。 Tableview标题的框架为零! (我需要使用reloadSections,因为我想为它设置动画。reloadData()不会给出任何动画。
  3. 所以viewForHeaderInSection的一个非常淡化的例子是:

    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        // some code
         sectionView.setupUI()
        return sectionView
    }
    

    标题类:

    class SectionHeaderclass: UITableViewHeaderFooterView{
        func setupUI(){
            let triangleViewArea = ViewWithTriangleLine(triangleCenter:Double(contentView.frame.width - 30))
        }
    }
    
    如果我为部分重新加载动画,

    contentView.frame.width会返回0。为什么?!我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

如果你想更新标题,并且它有一些图纸视图,你最好在headerView上调用setNeedsDisplay()而不是重新加载tableview。 请注意reloadSections(...)更新标题视图中的单元格。

相关问题