One Logo Pool Ball
WidgetKit · IOS API REFERENCE

WidgetPreviewContext

struct · iOS 14.0+ · SDK 27.1

struct WidgetPreviewContext

A specification for the context of a widget preview. To create a preview for a widget in Xcode, use <doc://com.apple.documentation/documentation/swiftui/view/previewcontext(_:)> and pass `WidgetPreviewContext` initialized with the appropriate `WidgetFamily`. struct Widget_Previews: PreviewProvider { static var previews: some View { Group { MyWidgetView() .previewContext(WidgetPreviewContext(family: .systemSmall)) } } }

Members (1)

init · iOS 14.0+

init

TypeScript
static init(family: WidgetFamily): WidgetPreviewContext
Swift declaration
init(family: WidgetFamily)

Creates a context for previewing a widget or a widget's view. - Parameter family: The template the widget preview uses: small, medium, or large.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

WidgetPreviewContext.subscript(_:)

Passing a Swift type itself is not supported.

All WidgetKit types →