用法一
實例方法
accessibility
accessibilityRotor(_:textRanges:)
使用指定的 user-visible 標簽和每個指定範圍的條目創建一個輔助函數轉子。轉子將附加到當前的輔助函數元素,每個條目將進入該元素的指定範圍。
聲明
func accessibilityRotor(
_ labelKey: LocalizedStringKey,
textRanges: [Range<String.Index>]
) -> some View
參數
labelKey
向用戶標識此轉子的本地化標簽。
textRanges
將用於生成轉子條目的範圍數組。
詳述
輔助函數轉子是輔助函數用戶快速導航到用戶接口的特定元素以及這些元素中的特定文本範圍的快捷方式。
在以下示例中,消息應用程序添加了一個轉子,允許用戶瀏覽包含電子郵件地址的所有文本範圍。
extension Message {
// Ranges of special areas in the `content` text. Calculated
// when `content` is set and then cached so that we don't have
// to re-compute them.
var emailAddressRanges: [Range<String.Index>]
}
struct MessageContentView: View {
TextEditor(.constant(message.content))
.accessibilityRotor("Email Addresses",
textRanges: message.emailAddressRanges)
}
可用版本
iOS 15.0+, iPadOS 15.0+, macOS 12.0+, Mac Catalyst 15.0+, tvOS 15.0+, watchOS 8.0+
用法二
實例方法
accessibility
accessibilityRotor(_:textRanges:)
使用指定的 user-visible 標簽和每個指定範圍的條目創建一個輔助函數轉子。轉子將附加到當前的輔助函數元素,每個條目將進入該元素的指定範圍。
聲明
func accessibilityRotor(
_ label: Text,
textRanges: [Range<String.Index>]
) -> some View
參數
label
向用戶標識此轉子的本地化標簽。
textRanges
將用於生成轉子條目的範圍數組。
詳述
輔助函數轉子是輔助函數用戶快速導航到用戶接口的特定元素以及這些元素中的特定文本範圍的快捷方式。
在以下示例中,消息應用程序添加了一個轉子,允許用戶瀏覽包含電子郵件地址的所有文本範圍。
extension Message {
// Ranges of special areas in the `content` text. Calculated
// when `content` is set and then cached so that we don't have
// to re-compute them.
var emailAddressRanges: [Range<String.Index>]
}
struct MessageContentView: View {
TextEditor(.constant(message.content))
.accessibilityRotor("Email Addresses",
textRanges: message.emailAddressRanges)
}
可用版本
iOS 15.0+, iPadOS 15.0+, macOS 12.0+, Mac Catalyst 15.0+, tvOS 15.0+, watchOS 8.0+
用法三
實例方法
accessibility
accessibilityRotor(_:textRanges:)
創建一個可訪問性轉子來替換指定的係統提供的轉子。轉子將附加到當前的輔助函數元素,每個條目將進入該元素的指定範圍。
聲明
func accessibilityRotor(
_ systemRotor: AccessibilitySystemRotor,
textRanges: [Range<String.Index>]
) -> some View
參數
systemRotor
將被此自定義轉子覆蓋的係統提供的轉子。
textRanges
將用於生成轉子條目的範圍數組。
詳述
輔助函數轉子是輔助函數用戶快速導航到用戶接口的特定元素以及這些元素中的特定文本範圍的快捷方式。
在以下示例中,消息應用程序添加了一個轉子,允許用戶瀏覽包含標題的所有文本範圍。
extension Message {
// Ranges of special areas in the `content` text. Calculated when
// `content` is set and then cached so that we don't have to
// re-compute them.
var headingRanges: [Range<String.Index>]
}
struct MessageContentView: View {
TextEditor(.constant(message.content))
.accessibilityRotor(
.heading,
textRanges: message.headingRanges
)
}
可用版本
iOS 15.0+, iPadOS 15.0+, macOS 12.0+, Mac Catalyst 15.0+, tvOS 15.0+, watchOS 8.0+
用法四
實例方法
accessibility
accessibilityRotor(_:textRanges:)
使用指定的 user-visible 標簽和每個指定範圍的條目創建一個輔助函數轉子。轉子將附加到當前的輔助函數元素,每個條目將進入該元素的指定範圍。
聲明
func accessibilityRotor<L>(
_ label: L,
textRanges: [Range<String.Index>]
) -> some View where L : StringProtocol
參數
label
向用戶標識此轉子的本地化標簽。
textRanges
將用於生成轉子條目的範圍數組。
詳述
輔助函數轉子是輔助函數用戶快速導航到用戶接口的特定元素以及這些元素中的特定文本範圍的快捷方式。
在以下示例中,消息應用程序添加了一個轉子,允許用戶瀏覽包含電子郵件地址的所有文本範圍。
extension Message {
// Ranges of special areas in the `content` text. Calculated
// when `content` is set and then cached so that we don't have
// to re-compute them.
var emailAddressRanges: [Range<String.Index>]
}
struct MessageContentView: View {
TextEditor(.constant(message.content))
.accessibilityRotor("Email Addresses",
textRanges: message.emailAddressRanges)
}
可用版本
iOS 15.0+, iPadOS 15.0+, macOS 12.0+, Mac Catalyst 15.0+, tvOS 15.0+, watchOS 8.0+
相關用法
- Swift Optional accessibilityRotor(_:entries:entryID:entryLabel:)用法及代碼示例
- Swift Optional accessibilityRotor(_:entries:entryLabel:)用法及代碼示例
- Swift Optional accessibilityRotor(_:entries:)用法及代碼示例
- Swift Optional accessibilityRepresentation(representation:)用法及代碼示例
- Swift Optional accessibilityAction(named:_:)用法及代碼示例
- Swift Optional accessibilityAdjustableAction(_:)用法及代碼示例
- Swift Optional accessibilityChartDescriptor(_:)用法及代碼示例
- Swift Optional accessibilityAction(action:label:)用法及代碼示例
- Swift Optional accessibilityChildren(children:)用法及代碼示例
- Swift Optional accessibilityShowsLargeContentViewer()用法及代碼示例
- Swift Optional accessibilityAction(_:_:)用法及代碼示例
- Swift Optional accessibilityShowsLargeContentViewer(_:)用法及代碼示例
- Swift Optional accessibilityScrollAction(_:)用法及代碼示例
- Swift Optional alert(_:isPresented:presenting:actions:)用法及代碼示例
- Swift Optional alert(isPresented:error:actions:)用法及代碼示例
- Swift Optional alignmentGuide(_:computeValue:)用法及代碼示例
- Swift Optional alert(isPresented:error:actions:message:)用法及代碼示例
- Swift Optional alert(_:isPresented:presenting:actions:message:)用法及代碼示例
- Swift Optional autocorrectionDisabled(_:)用法及代碼示例
- Swift Optional aspectRatio(_:contentMode:)用法及代碼示例
- Swift Optional allowsTightening(_:)用法及代碼示例
- Swift Optional alert(_:isPresented:actions:message:)用法及代碼示例
- Swift Optional alert(_:isPresented:actions:)用法及代碼示例
- Swift Optional symbolVariant(_:)用法及代碼示例
- Swift Optional popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Optional accessibilityRotor(_:textRanges:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。