How do you set the duration for UICollectionView Animations?

后端 未结 9 2063
旧巷少年郎
旧巷少年郎 2020-12-12 17:07

I have a custom flow layout which is adjusting the attributes for cells when they are being inserted and deleted from the CollectionView with the following two functions, bu

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 17:35

    An update to @AshleyMills since forBaselineLayout is deprecated

    This works

    self.collectionView.performBatchUpdates({ () -> Void in
        let indexSet = IndexSet(0...(numberOfSections - 1))
        self.collectionView.insertSections(indexSet)
        self.collectionView.forFirstBaselineLayout.layer.speed = 0.5
    }, completion: { (finished) -> Void in
        self.collectionView.forFirstBaselineLayout.layer.speed = 1.0
    })
    

提交回复
热议问题