Instance Method


Returns the content offset to use after an animated layout update or change.


func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint



The proposed point (in the coordinate space of the collection view’s content view) for the upper-left corner of the visible content. This represents the point that the collection view has calculated as the most likely value to use at the end of the animation.

Return Value

The content offset that you want to use instead. The default implementation of this method returns the value in the proposedContentOffset parameter.


During layout updates, or when transitioning between layouts, the collection view calls this method to give you the opportunity to change the proposed content offset to use at the end of the animation. You might override this method if the animations or transition might cause items to be positioned in a way that is not optimal for your design.

The collection view calls this method after calling the prepare() and collectionViewContentSize methods.

See Also

Providing Layout Attributes

class var layoutAttributesClass: AnyClass

Returns the class to use when creating layout attributes objects.

func prepare()

Tells the layout object to update the current layout.

func layoutAttributesForElements(in: CGRect) -> [UICollectionViewLayoutAttributes]?

Returns the layout attributes for all of the cells and views in the specified rectangle.

func layoutAttributesForItem(at: IndexPath) -> UICollectionViewLayoutAttributes?

Returns the layout attributes for the item at the specified index path.

func layoutAttributesForInteractivelyMovingItem(at: IndexPath, withTargetPosition: CGPoint) -> UICollectionViewLayoutAttributes

Returns the layout attributes of an item when it is being moved interactively by the user.