Initializer

init(_:selection:content:)

Creates a picker that generates its label from a localized string key.

Declaration 宣言

init(_ titleKey: LocalizedStringKey, selection: Binding<SelectionValue>, content: () -> Content)
Available when Label is Text, SelectionValue conforms to Hashable, and Content conforms to View.

Parameters パラメータ

titleKey

A localized string key that describes the purpose of selecting an option.

selection

A binding to a property that determines the currently-selected option.

content

A view that contains the set of options.

Discussion 議論

This initializer creates a Text view on your behalf, and treats the localized key similar to init(_:tableName:bundle:comment:). See Text for more information about localizing strings. このイニシャライザは、Textビューをあなたに代わって作成します、そしてローカライズされたキーをinit(_:tableName:bundle:comment:)に似たものと見なします。Textを文字列のローカライズについてのさらなる情報として見てください。

To initialize a picker with a string variable, use init(_:selection:content:) instead.

See Also 参照

Creating a Picker ピッカー(選び出し集)を作成する