Im trying to implement scrollable stackview in my app but I cant get it to work.
When I click on the textfield, an uipicker is shown. Based on the selected row ( 1 to 15 ), an UIButton is added to stackview.
for index in 1...selectedRow+1 {
let button = UIButton()
button.setTitle("\(index)", for: .normal)
directionsStackView.addArrangedSubview(button)
}
This looks pretty good, unless the number is > 7
So Ive decided to implement UIScrollView to scroll through the stackview
The StackView has the alignment set to Fill and Distribution to Equal Spacing.
Constraints:
ScrollView has: Height Equals to 35, trailing and leading to margins
StackView has: trailing, leading, top, bottom to superview, equal height with superview, and aligned center X to superview ( superview is the scrollview )
The thing I want to accomplish is - the spacing between numbers should always be equal, and when the there are too many numbers ( 7+ ), do not modify the spacing between numbers to be less, just scroll through them horizontally.
I thought that increasing the width of stackview would work, but the problem is that i am not able to scroll through them.
screenshot: htt ps://imgur.com/a/roi38 (sorry for the space im not able to post 3+ links because of reputation)
Can anyone help me with this?
Thank you.