init(_:)
Creates labeled content based on a labeled content style configuration.
Declaration
init(_ configuration: LabeledContentStyleConfiguration)Parameters
- configuration:
The properties of the labeled content
Discussion
You can use this initializer within the makeBody(configuration:) method of a LabeledContentStyle to create a labeled content instance. This is useful for custom styles that only modify the current style, as opposed to implementing a brand new style.
For example, the following style adds a red border around the labeled content, but otherwise preserves the current style:
struct RedBorderLabeledContentStyle: LabeledContentStyle {
func makeBody(configuration: Configuration) -> some View {
LabeledContent(configuration)
.border(.red)
}
}