Instance Method

startInteractiveTransitionToCollectionViewLayout:completion:

Changes the collection view’s current layout using an interactive transition effect.

Declaration

- (UICollectionViewTransitionLayout *)startInteractiveTransitionToCollectionViewLayout:(UICollectionViewLayout *)layout completion:(UICollectionViewLayoutInteractiveTransitionCompletion)completion;

Parameters

layout

The new layout object for the collected views. This is the layout that you want the collection view to use after the interactive transition is done.

completion

A completion handler to execute after the transition finishes.

Return Value

The intermediate transition layout object responsible for managing the interactive transition behavior.

Discussion

Call this method when you want to change the layout of your collection view using an intermediate transition. When you call this method, the collection view quietly makes the returned transition layout object its current layout object. It is your responsibility to set up a gesture recognizer or other touch-event handling code to track the transition progress. As progress changes, update the transitionProgress property of the transition layout object and invalidate the layout. Invalidating its layout causes the transition layout object to update the position of items based on the new progress value.

When your event-handling code determines that the user has finished the transition to the new layout, call the finishInteractiveTransition method. If your code determines that the user has canceled the transition, call the cancelInteractiveTransition method to revert the changes instead. Calling either of these methods removes the transition layout object from the collection view and installs the appropriate target layout object.

This method returns an instance of the UICollectionViewTransitionLayout class by default. If you want it to return a custom transition object instead, implement the collectionView:transitionLayoutForOldLayout:newLayout: method of your collection view delegate and use that method to return your custom object.

See Also

Changing the Layout

collectionViewLayout

The layout used to organize the collected view’s items.

- setCollectionViewLayout:animated:

Changes the collection view’s layout and optionally animates the change.

- setCollectionViewLayout:animated:completion:

Changes the collection view’s layout and notifies you when the animations complete.

- finishInteractiveTransition

Tells the collection view to finish an interactive transition by installing the intended target layout.

- cancelInteractiveTransition

Tells the collection view to abort an interactive transition and return to its original layout object.

Customizing Collection View Layouts

Customize a view layout by changing the size of cells in the flow or implementing a mosaic style.