---
title: "#186: Focus Engine Basics on tvOS 📺"
url: https://littlebitesofcocoa.com/186-focus-engine-basics-on-tvos
author: Jake Marsh
published: 2016-02-08
topics: ["tvOS","UIKit"]
description: "One of the biggest things that sets tvOS apart from iOS is the Focus Engine. Today we'll check out what it does, how it works, and how we can interact with..."
---

# #186: Focus Engine Basics on tvOS 📺

By Jake Marsh, February 8, 2016. HTML: https://littlebitesofcocoa.com/186-focus-engine-basics-on-tvos

<img src='https://media.littlebitesofcocoa.com/bite-assets/186-focus-engine-basics-on-tvos-graphic.png' style='max-width: 333px; float: right; margin-left: 20px; margin-bottom: 20px;' />

One of the biggest things that sets **tvOS** apart from **iOS** is the _Focus Engine_. Today we'll check out what it does, how it works, and how we can interact with it in our **apps**. Let's get started.

The _Focus Engine_ is the part of **tvOS** that manages which **view** the user is currently focused on in **tvOS's** interface, as well as moving to another **view** when the user performs a gesture on their remote (or a game controller). 

We get all of this functionality "for free", as long as we're using **UIKit** controls to construct the UI of our apps.

The _Focus Engine_ will listen for a user's input like a **left swipe**, then it will look for **views** that are currently to the left on screen of the currently focused **view**, and move focus to them.

For many **apps**, that's really all there is to it. 1.) Construct our UI, 2.) _Focus Engine_ handles it all.

For more advanced usage, there's a few places we can "hook into" and interact with the _Focus Engine_. Here's some examples:

- We can update the currently focused **view** in a similar way to how make layout changes on **iOS**. First we override the `preferredFocusView` **property** on our **UIViewController**, then we call `setNeedsFocusUpdate`. <i>(Only works if the view controller already contains the currently focused view).</i>

- We can have the system ask us if it's ok to make a proposed focus change. For this we'd implement `shouldUpdateFocusInContent` on our **view controllers**, answering ‘yes' or ‘no'. 

- Lastly, we can use the `didUpdateFocusInContext` **function** to (for example) animate our custom **views** alongside the system's animations.
