最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

uikit - Animating performBatchUpdates in UICollectionView - how to remove the fade style? - Stack Overflow

programmeradmin6浏览0评论

I have a typical "select a row, slide it up to the top" animation ...

    data .. update to the final data
    coll.performBatchUpdates({
        coll.deleteSections(removeIndexPathSections)
        coll.moveSection(indexPathOfTargetRow, toSection: 0)
        
    }) { _ in
        completion()
    }

So, the rows of the collection

A
B
C
D
E

the user clicks "D" row and we get

D

ie removeIndexPathSections1 would be [0,1,2,4]

and indexPathOfTargetRow would be 3

This works fine but what happens in detail is

  1. the four rows fade away over the half second

  2. the "D" row slides up to the top position over the same half-second

That's fine but I would prefer

  1. the four rows instantly disappear

  2. the "D" row slides up to the top position over a half-second

I can't find a way to do this. Is it possible?


My workaround is just to run this sort of code first ..

    let viz = coll.indexPathsForVisibleItems
    for v in viz {
        if v.section == 0 { continue }
        if v.section == indexPathOfTargetRow { continue }
        coll.cellForItem(at: v)?.isHidden = true
        // don't fet due to this you have to unhide
        // in prepareForReuse every cell type used :/
    }
    .. then the above code ..

.. which is a shame.

In related approaches,

  1. perhaps there's a way to run the two animations sequentially versus simultaneously?

  2. perhaps you can set the animation time, or, each of the two animations differently?

  3. You can changed the peed with coll.forFirstBaselineLayout.layer.speed = .. but I could not find how to independently change the two animations.

Any ideas ?

发布评论

评论列表(0)

  1. 暂无评论