body
The constraints of the formatting definition.
Declaration
@AttributedTextFormatting.DefinitionBuilder<Self.Scope> var body: Self.Body { get }Discussion
When you implement a custom definition, you must implement a computed body property to provide the constraints of your definition. Return a definition that’s composed of built-in definitions that SwiftUI provides, such as AttributedTextFormattingDefinition.ValueConstraint and AttributedTextValueConstraints, plus other composite AttributedTextFormattingDefinitions that you’ve already defined:
struct MyTextFormattingDefinition: AttributedTextFormattingDefinition {
var body: some AttributedTextFormattingDefinition<
AttributeScopes.SwiftUIAttributes
> {
ValueConstraint(
for: \.underlineStyle,
values: [nil, .single],
default: .single)
MyAttributedTextValueConstraint()
}
}Note that the order of the constraints in the result builder matters as constraints are applied in order. For details, see AttributedTextValueConstraint/constrain(_:)-(Attributes).