如何使用swift 3使UICollectionview中的最后一行变为粘滞

时间:2017-09-01 03:30:01

标签: swift3 uicollectionview

我在UICollectionView中使用多方向滚动和自定义流布局来创建数字表。

表的结构应该是这样的。一个数字表,其在最后一行中具有总和值:

The structure of the table should be like this. A numeric table which has the sum up value in the last row

现在表的第一列和第一行是静态的,即粘性的。我希望最后一行也可以粘贴在视图的底部。请帮助我。

这是我目前对该表的看法:

This is my current view of the table

提前谢谢你。

1 个答案:

答案 0 :(得分:1)

if section == sectionCount-1 {

    for item in 0...rowCount-1 {
         let indexPath = IndexPath(item: item, section: section)                                
         if let attrs = cellAttrsDictionary[indexPath] {
              var frame = attrs.frame            
              if item == 0 {                 
                  // Assigning the size of the first column as 200
                  frame.size.width = 200
                  frame.origin.x = xOffset
              }

              // Configuration for the last row in the last cell.

              // Subtracting the Cell height from the entire Collection View height and assigning it as the frame for the last row of the Table i.e precisely on Y position.

              frame.origin.y = (collectionView?.frame.size.height)! + yOffset - CGFloat(CELL_HEIGHT)
              attrs.frame = frame
         }                 
    }
}