CollectionViewPreviewTransitionCell

public protocol CollectionViewPreviewTransitionCell : AnyObject

A protocol for CollectionViewCells that need to customize their transition when used in CollectionViewPreviewController.

If you adopt this protocol in a custom CollectionViewCell subclass, see the source code for CollectionViewPreviewCell for an example implementation.

  • Called just before the transition animation to prepare the cell

    Update the cell to prepare for transition from the item at indexPath in collectionView. Typically this will include fetching the layout attributes and/or cell using the provided index path and collection view, then applying the frame to self.

    Declaration

    Swift

    func prepareForTransition(fromItemAt indexPath: IndexPath, in collectionView: CollectionView, to layoutAttributes: CollectionViewLayoutAttributes)

    Parameters

    indexPath

    The indexPath of the source cell

    collectionView

    The source collection view

    layoutAttributes

    The final layout attributes for the receiver

  • Called within the animation block in which the cell should moved from the source position to the destination position

    Update the cell to position and style as needed to transition from it’s source. Typically this will include fetching the layout attributes and/or cell using the provided index path and collection view, then applying the frame to self.

    Declaration

    Swift

    func transition(fromItemAt indexPath: IndexPath, in collectionView: CollectionView, to layoutAttributes: CollectionViewLayoutAttributes)

    Parameters

    indexPath

    The index path of the source item

    collectionView

    The source collection view

    layoutAttributes

    The final layout attributes of the receiver

  • Called when the transition from the source has completed and the cell is in it’s final position.

    Declaration

    Swift

    func finishTransition(fromItemAt indexPath: IndexPath, in collectionView: CollectionView)

    Parameters

    indexPath

    The index path of the source item

    collectionView

    The source collection view

  • Called just before the cell is transitioned back to it’s source

    Declaration

    Swift

    func prepareForTransition(toItemAt indexPath: IndexPath, in collectionView: CollectionView)

    Parameters

    indexPath

    The index path of the source item

    collectionView

    The source collection view

  • Called within the transition animation block in which the cell should move back to its source.

    Update the cell to position and style as needed to transition back to it’s source. Typically this will include fetching the layout attributes and/or cell using the provided index path and collection view, then applying the frame to self.

    Declaration

    Swift

    func transition(toItemAt indexPath: IndexPath, in collectionView: CollectionView)

    Parameters

    indexPath

    The index path of the source item

    collectionView

    The source collection view

  • Called when the transition back to the source has completed and the containing preview controller will be removed.

    Declaration

    Swift

    func finishTransition(toItemAt indexPath: IndexPath, in collectView: CollectionView)

    Parameters

    indexPath

    The index path of the source item

    collectionView

    The source collection view