Structure¶
WidgetBundleBuilder¶
A custom attribute that constructs a widget bundle's body.¶
Declaration¶
@\_functionBuilder struct WidgetBundleBuilder
Overview¶
Use the @WidgetBundleBuilder attribute to group multiple widgets listed in the WidgetBundle/body-swift.property property of a widget bundle. For example, the following code defines a widget bundle that consists of two widgets.
@main
struct GameWidgets: WidgetBundle {
@WidgetBundleBuilder
var body: some Widget {
GameStatusWidget()
CharacterDetailWidget()
}
}
Availability¶
iOS 14.0+
macOS 11.0+
Topics¶
Type Method¶
buildBlock() Builds an empty Widget from an block containing no statements, { }.
buildBlock(_:) Builds a single Widget written as a child view (e..g, { MyWidget() }) through unmodified.
buildBlock(_:_:) Builds a new widget from a block containing 2 widgets.
buildBlock(_:_:_:) Builds a new widget from a block containing 3 widgets.
buildBlock(_:_:_:_:) Builds a new widget from a block containing 4 widgets.
buildBlock(_:_:_:_:_:) Builds a new widget from a block containing 5 widgets.