A set of methods that define the focus behavior for a branch of the view hierarchy.


The UIFocusEnvironment protocol provides a common interface for specifying and reacting to focus behavior throughout your app. Classes in UIKit that conform to this protocol include UIView, UIViewController, UIWindow, and UIPresentationController; in other words, classes that are either directly or indirectly in control of views on the screen. Third-party classes should not conform to the UIFocusEnvironment protocol.


Requesting Focus Update

When to request a focus update.

func setNeedsFocusUpdate()

Submits a request to the focus engine for a focus update in this environment.


func updateFocusIfNeeded()

Tells the focus engine to force a focus update immediately.


Validating Focus Movements

func shouldUpdateFocus(in: UIFocusUpdateContext)

Returns a Boolean value indicating whether the focus engine should allow the focus update described by the specified context to occur.


Responding to Focus Updates

func didUpdateFocus(in: UIFocusUpdateContext, with: UIFocusAnimationCoordinator)

Called immediately after the system updates the focus to a new view.


Controlling User-Generated Focus Movements

var preferredFocusEnvironments: [UIFocusEnvironment]

An array of focus environments, ordered by priority, to which this environment prefers focus to be directed during a focus update.


var preferredFocusedView: UIView?

Specifies the view that should be focused if this environment is focused.


Checking the Ancestory of the Environment

func contains(UIFocusEnvironment)

Returns a Boolean value indicating whether the current focus environment contains the specified environment.

Getting the Sound to Play During Updates

Using Custom Sounds for Focus Movement

Customize the sounds users hear when focus moves.

func soundIdentifierForFocusUpdate(in: UIFocusUpdateContext)

Asks the delegate for the identifier of the sound to play when the object gains focus.

struct UIFocusSoundIdentifier

An identifier for a focus-related sound.


Inherits From

Inherited By

See Also

Focus Interactions

About Focus Interactions for Apple TV

Design and implement intuitive control schemes for menus and interactive user interface layouts.

Adding User-Focusable Elements to a tvOS App

Create intuitive and easily manipulated user-interactive controls for your tvOS app.

class UIFocusSystem

The current state of the user interface's focus system.

class UIFocusUpdateContext

An object that provides information relevant to a specific focus update from one view to another.

protocol UIFocusItem

A protocol—not intended for conformance by third-party classes—that lets an item declare its ability to participate in the focus system.