Adding a control widget
WidgetKit provides ways to present our apps in the springboard. However, it doesn’t stop there. Starting iOS 18, it is possible to present widgets in the control center and on the lock screen and even attach an App Intent to the action button in iPhone 15 Pro.
Adding a widget to the control center or the lock screen is easy.
Similar to how we create a widget by conforming to the Widget protocol, we need to conform to the ControlWidget
protocol to create a control widget. For example, imagine we have an app that helps us control smart home accessories, and we want to create a widget that opens and closes our home’s main door. Let’s start by creating a simple control widget called MaindoorControl
:
struct MaindoorControl: ControlWidget { var body: some ControlWidgetConfiguration { StaticControlConfiguration( ...