實例方法
search
searchCompletion(_:)
將完全形成的字符串與此視圖的值相關聯。
聲明
func searchCompletion(_ completion: String) -> some View
參數
text
用作視圖完成的字符串。
詳述
使用此方法將完整格式的字符串與搜索建議列表上下文中的視圖相關聯。 The system uses this value when the view is selected to replace the partial text being currently edited of the associated search field.
在 tvOS 上,您提供給 this 修飾符的字符串在顯示相關建議和替換搜索字段的部分文本時使用。
SearchPlaceholderView()
.searchable(text: $text) {
Text("🍎").searchCompletion("apple")
Text("🍐").searchCompletion("pear")
Text("🍌").searchCompletion("banana")
}
可用版本
iOS 15.0+, iPadOS 15.0+, macOS 12.0+, Mac Catalyst 15.0+, tvOS 15.0+, watchOS 8.0+
相關用法
- Swift Optional symbolVariant(_:)用法及代碼示例
- Swift Optional saturation(_:)用法及代碼示例
- Swift Optional submitLabel(_:)用法及代碼示例
- Swift Optional speechAlwaysIncludesPunctuation(_:)用法及代碼示例
- Swift Optional submitScope(_:)用法及代碼示例
- Swift Optional scaledToFill()用法及代碼示例
- Swift Optional safeAreaInset(edge:alignment:spacing:content:)用法及代碼示例
- Swift Optional simultaneousGesture(_:including:)用法及代碼示例
- Swift Optional shadow(color:radius:x:y:)用法及代碼示例
- Swift Optional sheet(item:onDismiss:content:)用法及代碼示例
- Swift Optional scaledToFit()用法及代碼示例
- Swift Optional scenePadding(_:)用法及代碼示例
- Swift Optional scaleEffect(_:anchor:)用法及代碼示例
- Swift Optional scaleEffect(x:y:anchor:)用法及代碼示例
- Swift Optional swipeActions(edge:allowsFullSwipe:content:)用法及代碼示例
- Swift Optional sheet(isPresented:onDismiss:content:)用法及代碼示例
- Swift Optional popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代碼示例
- Swift Optional mask(alignment:_:)用法及代碼示例
- Swift Optional listSectionSeparatorTint(_:edges:)用法及代碼示例
- Swift Optional badge(_:)用法及代碼示例
- Swift Optional fullScreenCover(isPresented:onDismiss:content:)用法及代碼示例
- Swift Optional keyboardType(_:)用法及代碼示例
- Swift Optional clipShape(_:style:)用法及代碼示例
- Swift Optional preferredColorScheme(_:)用法及代碼示例
- Swift Optional background(_:ignoresSafeAreaEdges:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Optional searchCompletion(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。