Reputation: 2634
If the content of the ScrollView is bigger than the screen, while scrolling, the scrollbar on the side appears. I couldn't find anything to help me hide it.
Upvotes: 87
Views: 42797
Reputation: 376
From iOS 16, you can use:
ScrollView {
...
}
.scrollIndicators(.hidden)
Upvotes: 7
Reputation: 11426
if you need to hide both scrollers:
ScrollView(showsIndicators: false) {
//your code
}
__
If you need to hide only one scroller, but to have ability to scroll in both directions:
need to use Introspect:
ScrollView() {
// Some Content
}
.introspectScrollView{
$0.hasHorizontalScroller = false
$0.hasVerticalScroller = true
}
as result:
Upvotes: 7
Reputation: 341
Hide Indicators in ScrollView SwiftUI
ScrollView(.horizontal,showsIndicators: false) {
//your code
}
Show Indicators in ScrollView SwiftUI
ScrollView(.horizontal,showsIndicators: true) {
//your code
}
Upvotes: 1
Reputation: 5107
You just have to use the scrollView initializer and set the parameter showsIndicators property to false within the initializer only.
ScrollView(.vertical, showsIndicators: false) {
//your content for scrollView
}
Hope this has resolved your query.
Upvotes: 7
Reputation: 3780
You can use showsIndicators: false
to hide the indicator:
ScrollView(showsIndicators: false) {
// ...
}
Upvotes: 195