How do I implement the new Controls API ?
Asked on 2024-07-19
1 search
To implement the new Controls API introduced at WWDC 2024, you can follow these steps:
-
Understand What Controls Are: Controls are a new type of widget in iOS 18 that allow you to extend your app's functionality into system spaces like the control center, lock screen, and action button. They focus on actions and succinct information, making them ideal for quick tasks like turning on the flashlight or deep linking into an app.
-
Types of Controls: There are two types of controls:
- Buttons: Perform discrete actions, which can include launching your app.
- Toggles: Change a piece of boolean state, like turning something on or off.
-
Creating a Control: Controls are built using WidgetKit and are similar to building a widget. Here’s a basic outline:
- Define the control type (button or toggle).
- Use an app intent to perform the action.
- Provide a symbol, title, tint color, and additional content to the system.
-
Configuring a Control:
- Use the
control widget buttonfor buttons. - Use the
control widget statusmodifier to convey additional information about the control’s action or state. - Customize the display name and description of your control for better user understanding.
- Use the
-
Example: Here’s a simple example to create a button control:
struct MyControl: Widget { var body: some WidgetConfiguration { IntentConfiguration(kind: "MyControl", intent: MyControlIntent.self, provider: MyControlProvider()) { entry in MyControlView(entry: entry) } .configurationDisplayName("My Control") .description("This is an example control.") .supportedFamilies([.systemSmall]) } } -
Adding to System Spaces: Once defined, your control will be available in the new controls gallery, where users can add it to their control center, lock screen, or action button.
For a detailed walkthrough, you can refer to the session Extend your app’s controls across the system.
Relevant Sessions
- Extend your app’s controls across the system
- Platforms State of the Union
- What’s new in SwiftUI
- Bring your app’s core features to users with App Intents
These sessions provide comprehensive information on how to implement and refine controls in your app.

Platforms State of the Union
Discover the newest advancements on Apple platforms.

Bring your app’s core features to users with App Intents
Learn the principles of the App Intents framework, like intents, entities, and queries, and how you can harness them to expose your app’s most important functionality right where people need it most. Find out how to build deep integration between your app and the many system features built on top of App Intents, including Siri, controls and widgets, Apple Pencil, Shortcuts, the Action button, and more. Get tips on how to build your App Intents integrations efficiently to create the best experiences in every surface while still sharing code and core functionality.

What’s new in SwiftUI
Learn how you can use SwiftUI to build great apps for any Apple platform. Explore a fresh new look and feel for tabs and documents on iPadOS. Improve your window management with new windowing APIs, and gain more control over immersive spaces and volumes in your visionOS apps. We’ll also take you through other exciting refinements that help you make expressive charts, customize and layout text, and so much more.
