用法一
實例方法
text
textContentType(_:)
設置此視圖的文本內容類型,當用戶在 macOS 上輸入文本時,係統使用該類型提供建議。
聲明
func textContentType(_ textContentType: NSTextContentType?) -> some View
參數
textContentType
NSTextContentType
詳述
使用此方法設置輸入文本的內容類型。例如,您可以為用戶名條目配置TextField
:
TextField("Enter your username", text: $username)
.textContentType(.username)
可用版本
macOS 11.0+
用法二
實例方法
text
textContentType(_:)
設置此視圖的文本內容類型,當用戶在 iOS 或 tvOS 設備上輸入文本時,係統使用該類型提供建議。
聲明
func textContentType(_ textContentType: UITextContentType?) -> some View
參數
textContentType
UITextContentType
詳述
使用此方法設置輸入文本的內容類型。例如,您可以為電子郵件地址的條目配置 TextField
:
TextField("Enter your email", text: $emailAddress)
.textContentType(.emailAddress)
可用版本
iOS 13.0+, iPadOS 13.0+, Mac Catalyst 13.0+, tvOS 13.0+
用法三
實例方法
text
textContentType(_:)
設置此視圖的文本內容類型,當用戶在 watchOS 設備上輸入文本時,係統會使用該類型提供建議。
聲明
func textContentType(_ textContentType: WKTextContentType?) -> some View
參數
textContentType
WKTextContentType
詳述
使用此方法設置輸入文本的內容類型。例如,您可以為電子郵件地址的條目配置 TextField
:
TextField("Enter your email", text: $emailAddress)
.textContentType(.emailAddress)
可用版本
watchOS 6.0+
相關用法
- Swift Optional textSelection(_:)用法及代碼示例
- Swift Optional textInputAutocapitalization(_:)用法及代碼示例
- Swift Optional toolbar(id:content:)用法及代碼示例
- Swift Optional tint(_:)用法及代碼示例
- Swift Optional toolbar(content:)用法及代碼示例
- Swift Optional tabItem(_:)用法及代碼示例
- Swift Optional touchBarItemPresence(_:)用法及代碼示例
- Swift Optional touchBar(_:)用法及代碼示例
- Swift Optional task(priority:_:)用法及代碼示例
- Swift Optional touchBar(content:)用法及代碼示例
- Swift Optional toggleStyle(_:)用法及代碼示例
- Swift Optional transaction(_:)用法及代碼示例
- Swift Optional touchBarCustomizationLabel(_:)用法及代碼示例
- Swift Optional truncationMode(_:)用法及代碼示例
- Swift Optional tag(_:)用法及代碼示例
- Swift Optional transformEffect(_:)用法及代碼示例
- Swift Optional task(id:priority:_:)用法及代碼示例
- Swift Optional touchBarItemPrincipal(_:)用法及代碼示例
- Swift Optional symbolVariant(_:)用法及代碼示例
- 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(_:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Optional textContentType(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。