Search code examples
iosswiftiphoneuicollectionviewcell

UICollectionView: reload data, without removing an in-cell animation


I have progressBar with an ongoing progress-animation inside of a UICollectionViewCell. Every time I reload data of UICollectionView, the progress-animation gets removed. I have to reload data every time the number of cells changes.


Solution

  • Use collectionView visibleCells property. This way you have more control on the specific UI you want to UPDATE.

    for example. you have array of strings and dates. the string is animation. the date is simple label. you want to update only the dates.

    so :
    1. you update the data (array) with the new dates.
    2. you update the UI by calling collectionView visibleCells and then for each cell,
    3. you update only the date with the new info. the animation keep going.