Omer Naveed
Omer Naveed

Reputation: 97

How to hide scrollbar in UIStackView?

I am using Xcode 10.1 and am programming using Swift in the ViewController.swift file.

I have a horizontally scrolling UIStackView that works perfectly. The only issue is that the scrollbar appears whenever I begin to scroll. I looked online and there were plenty of tutorials on how to make similar UIStackViews but none of them explained how to hide the scrollbar. Does anybody know how to do this?

stackView.showsHorizontalScrollIndicator = false

Gives me the error

"Value of type 'UIStackView' has no member 'showsHorizontalScrollIndicator' "

Upvotes: 1

Views: 954

Answers (2)

Tiran Ut
Tiran Ut

Reputation: 1046

showsHorizontalScrollindicator is property of UIScrollView, but not the UIStackView

https://developer.apple.com/documentation/uikit/uiscrollview/1619380-showshorizontalscrollindicator

To hide scrollIndicator set this to false for your scrollView

Upvotes: 0

Kuldeep Tanwar
Kuldeep Tanwar

Reputation: 3526

First thing is you need to call showsHorizontalScrollIndicator On you scrollview. Second there are two ways of doing this : -

1 Programatically

// To hide vertical Indicator
scrollView.showsVerticalScrollIndicator = false
// To hide horizontal Indicator
scrollView.showsHorizontalScrollIndicator = false

2 By Storyboard

Select you scrollview and uncheck the following buttons

enter image description here

Upvotes: 1

Related Questions