Instance Method

collectionView(_:didUpdateFocusIn:with:)

Tells the delegate that a focus update occurred.

Declaration

optional func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context: UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator)

Parameters

collectionView

The collection view object notifying you of the focus change.

context

The context object containing metadata associated with the focus change. This object contains the index path of the previously focused item and the currently focused item.

coordinator

The animation coordinator to use when creating any additional animations.

Discussion

The collection view calls this method when a focus-related change occurs. You can use this method to update your app’s state information or to animate changes to your app’s visual appearance.

If you subclass UICollectionView, you can also implement the same behavior by overriding the didUpdateFocus(in:with:) method, which is defined by the UIFocusEnvironment protocol and adopted by all views.

See Also

Managing Focus in a Collection View

func collectionView(UICollectionView, canFocusItemAt: IndexPath) -> Bool

Asks the delegate whether the item at the specified index path can be focused.

func indexPathForPreferredFocusedView(in: UICollectionView) -> IndexPath?

Asks the delegate for the index path of the cell that should be focused.