0

How can i animate the loading of cells into a collectionview.

Ive been playing with the following code but it only animates cells that are off screen when i scroll.

How to animate the all the cells not the screen to start?

    let finalFrame: CGRect = cell.frame
        cell.frame = CGRect(x: finalFrame.origin.x - 1000, y: -500, width: 0, height: 0)

    UIView.animate(withDuration: 0.5, animations: {
        cell.frame = finalFrame
    })
WanderingScouse
  • 281
  • 1
  • 3
  • 16

1 Answers1

2

Use performBatchUpdates(_:completion:)

And inside the performBatchUpdates block:

For items:

Insert: insertItems(at:)

Delete: deleteItems(at:)

Move/Reorder: moveItem(at:to:)

For sections:

Insert: insertSections(_:)

Delete: deleteSections(_:)

Move/Reorder: moveItem(at:to:)

If you want to further customize your animations:

1: Check this thread

2: YouTube tutorial

3: Github Project

4: Alternative UIStackView for Swift 3 Youtube Tutorial

Community
  • 1
  • 1