Contents

init(_:value:format:)

Creates a labeled informational view from a formatted value.

Declaration

init<F>(_ titleKey: LocalizedStringKey, value: F.FormatInput, format: F) where F : FormatStyle, F.FormatInput : Equatable, F.FormatOutput == String

Parameters

  • titleKey:

    The key for the view’s localized title, that describes the purpose of the view.

  • value:

    The value being labeled.

  • format:

    A format style of type F to convert the underlying value of type F.FormatInput to a string representation.

Discussion

This initializer creates a Text label on your behalf, and treats the localized key similar to init(_:tableName:bundle:comment:). See Text for more information about localizing strings.

Form {
    LabeledContent("Age", value: person.age, format: .number)
    LabeledContent("Height", value: person.height,
        format: .measurement(width: .abbreviated))
}

See Also

Creating labeled content