我有一个带有Flow Layout的UICollectionView。 我想设置要一个接一个显示的单元的动画。 因此,第一个单元格来自屏幕底部,第二个单元格紧随其后(稍有延迟)并位于第一个单元格下方,依此类推。 我找不到任何可以帮助我实现这一目标的东西。 这是我到目前为止尝试过的:
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
let spacing: CGFloat = 8
let originX: CGFloat = cell.frame.origin.x
let cellHeight: CGFloat = cell.frame.size.height + spacing
cell.frame.origin = CGPoint(x: originX, y: UIScreen.main.bounds.height)
UIView.animate(withDuration: 4, delay: 0.1, options: .curveEaseInOut, animations: {
cell.frame.origin = CGPoint(x: originX, y: cellHeight * CGFloat(indexPath.row))
}, completion: nil)
}
虽然这些单元格是从底部发出的,但我找不到如何在彼此之间稍加延迟以达到那种效果的方法。