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)")
}
.scrollIndicators(.hidden)
}
}
Download this as an Xcode project
There are four options available to us, and there are subtle distinctions:
.automatic
, which is what you’d get without the modifier in place - SwiftUI will do whatever it thinks is best..visible
to get auto-hiding indicators on iOS, or to respect whatever is the user’s preference on macOS. .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..never
to hide the indicators on iOS and also on macOS, regardless of what pointing device user has.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!
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.