targetContentOffset(forProposedContentOffset:)
Retrieves the content offset to use after an animated layout update or change.
Declaration
func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint) -> CGPointParameters
- proposedContentOffset:
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.
Discussion
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
layoutAttributesClassprepare()layoutAttributesForElements(in:)layoutAttributesForItem(at:)layoutAttributesForInteractivelyMovingItem(at:withTargetPosition:)layoutAttributesForSupplementaryView(ofKind:at:)layoutAttributesForDecorationView(ofKind:at:)targetContentOffset(forProposedContentOffset:withScrollingVelocity:)