Skip to main content

How to hide the scroll indicators in ScrollView, List, and more

About 2 minSwiftSwiftUIArticle(s)bloghackingwithswift.comcrashcourseswiftswiftuixcodeappstore

How to hide the scroll indicators in ScrollView, List, and more 관련

SwiftUI by Example

Back to Home

How to hide the scroll indicators in ScrollView, List, and more | SwiftUI by Example

How to hide the scroll indicators in ScrollView, List, and more

Updated for Xcode 15

New in iOS 16

SwiftUI's scrollIndicators() modifier allows us to determine whether to show the scroll indicators or not – those are the little flashing bars that both give the user a sense of the size of our content, but also allows for a long press scroll.

Use it like this:

struct ContentView: View {
    var body: some View {
        List(1..<100) { i in
            Text("Row \(i)")
        }
        .scrollIndicators(.hidden)
    }
}

Download this as an Xcode projectopen in new window

There are four options available to us, and there are subtle distinctions:

  1. The default is .automatic, which is what you'd get without the modifier in place - SwiftUI will do whatever it thinks is best.
  2. Specify .visible to get auto-hiding indicators on iOS, or to respect whatever is the user's preference on macOS.
  3. Use .hidden to hide the indicators on iOS, and mostly hide them on macOS too – if the user connects a mouse, the scroll indicators will return.
  4. Use .never to hide the indicators on iOS and also on macOS, regardless of what pointing device user has.
Similar solutions…
How to flash the scroll bar indicators of a ScrollView or List | SwiftUI by Example

How to flash the scroll bar indicators of a ScrollView or List
How to indent the content or scroll indicators in a ScrollView | SwiftUI by Example

How to indent the content or scroll indicators in a ScrollView
How to scroll to a specific row in a list | SwiftUI by Example

How to scroll to a specific row in a list
How to hide the label of a Picker, Stepper, Toggle, and more using labelsHidden() | SwiftUI by Example

How to hide the label of a Picker, Stepper, Toggle, and more using labelsHidden()
How to make views scroll with a custom transition | SwiftUI by Example

How to make views scroll with a custom transition

이찬희 (MarkiiimarK)
Never Stop Learning.