Instance Method インスタンスメソッド

searchCompletion(_:)

Associates a fully formed string with the value of this view.

Declaration 宣言

func searchCompletion(_ completion: String) -> some View

Parameters パラメータ

text

A string to use as the view’s completion.

Discussion 議論

Use this method to associate a fully formed string with a view that is within a search suggestion list context. The system uses this value when the view is selected to replace the partial text being currently edited of the associated search field.

On tvOS, the string that you provide to the this modifier will be used when displaying the associated suggestion and when replacing the partial text of the search field.


SearchPlaceholderView()
    .searchable(text: $text) {
        Text("🍎").searchCompletion("apple")
        Text("🍐").searchCompletion("pear")
        Text("🍌").searchCompletion("banana")
    }