Updated for Xcode 14.0 beta 1
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 You know StoreKit, but you don’t want to do StoreKit. RevenueCat makes it easy to deploy, manage, and analyze in-app subscriptions on iOS and Android so you can focus on building your app.
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.