Hamoonist
Hamoonist

Reputation: 2634

How can I hide/remove ScrollBar in ScrollView in SwiftUI?

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

Answers (5)

NES8
NES8

Reputation: 376

From iOS 16, you can use:

ScrollView {
    ...
}
.scrollIndicators(.hidden)

Upvotes: 7

Andrew
Andrew

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:

  • horisontal scroller invisible
  • vertical scroller visible;

Upvotes: 7

Chithian
Chithian

Reputation: 341

Show / Hide Indicators in ScrollView SwiftUI

Hide Indicators in ScrollView SwiftUI

  ScrollView(.horizontal,showsIndicators: false) {
  //your code
  }

Show Indicators in ScrollView SwiftUI

 ScrollView(.horizontal,showsIndicators: true) {
  //your code
  }

Upvotes: 1

Nirav Jain
Nirav Jain

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

JWK
JWK

Reputation: 3780

You can use showsIndicators: false to hide the indicator:

ScrollView(showsIndicators: false) {
    // ...
}

Upvotes: 195

Related Questions