Contents

accessibilityScrollStatus(_:isEnabled:)

Changes the announcement provided by accessibility technologies when a user scrolls a scroll view within this view.

Declaration

nonisolated func accessibilityScrollStatus(_ status: LocalizedStringResource, isEnabled: Bool = true) -> ModifiedContent<Content, Modifier>

Parameters

  • status:

    The current status of the scroll view.

  • isEnabled:

    If true the accessibility scroll status is applied; otherwise the accessibility scroll status is unchanged.

Discussion

Use this modifier to provide a description of the content at the current position in the scroll view. For example, you could use this modifier to announce the current month being scrolled to in a view that contains a calendar.

@State private var position = ScrollPosition(idType: Month.ID.self)

ScrollView {
    LazyVStack {
        ForEach(months) { months in
            MonthView(month: months)
        }
    }
    .scrollTargetLayout()
}
.scrollPosition($position)
.accessibilityScrollStatus("\(months.name(position.viewID)) \(year)")

By default, VoiceOver announces “Page X of Y” while scrolling.