【问题标题】:Simple collectionView animation简单的collectionView动画
【发布时间】:2017-02-23 22:36:24
【问题描述】:

如何将单元格加载到集合视图中。

我一直在使用以下代码,但它只会在我滚动时为屏幕外的单元格设置动画。

如何为所有单元格设置动画而不是屏幕启动?

    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
    })

【问题讨论】:

    标签: ios swift animation uicollectionview


    【解决方案1】:

    使用performBatchUpdates(_:completion:)

    performBatchUpdates 块内:

    发给 items:

    插入:insertItems(at:)

    删除:deleteItems(at:)

    移动/重新排序:moveItem(at:to:)

    发给sections

    插入:insertSections(_:)

    删除:deleteSections(_:)

    移动/重新排序:moveItem(at:to:)

    如果您想进一步自定义动画:

    1:Check this thread

    2:YouTube tutorial

    3:Github Project

    4:Alternative UIStackView for Swift 3 Youtube Tutorial

    【讨论】:

      猜你喜欢
      • 2016-09-28
      • 2014-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-26
      • 2012-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多