NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

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

Paul Hudson    @twostraws   

Updated for Xcode 14.2

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)")

Download this as an Xcode project

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.
Hacking with Swift is sponsored by Essential Developer

SPONSORED From March 20th to 26th, you can join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer!

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Similar solutions…

Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

Average rating: 5.0/5

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.