How to determine when a custom UICollectionViewCell is 100% on the screen

前端 未结 3 571
我在风中等你
我在风中等你 2020-12-29 08:21

From the diagram above I have UICollectionView with 4 custom cells. At any time 2 or three cells can be on the screen. How can I tell when \"cell 1\"

3条回答
  •  别那么骄傲
    2020-12-29 09:13

    You can filter your visibleCells array to check if the frame of your cell is included in the frame of your collectionView:

        var visibleCells = self.collectionView?.visibleCells
        visibleCells = visibleCells?.filter({ cell -> Bool in
            return self.collectionView?.frame.contains(cell.frame) ?? false
        })
        print (visibleCells)
    

提交回复
热议问题