I'm currently working on a swiftUI project where I'm supposed to be able to interact with the content of a scrollView. The problem is that I want to scroll only using buttons. It works but I can't figure a way to disable the scrolling without disabling the content of my ScrollView
Here's my code. I know that disabled(true)
won't work but it's what I got so far
ScrollViewReader { scrolling in
ZStack{
HStack{
ScrollView(.horizontal, showsIndicators: false){
HStack{
FirstStepView().id(0).padding(.horizontal,20).frame(width: UIScreen.main.bounds.width)
SecondStepView().id(1).frame(width: UIScreen.main.bounds.width)
ThirdStepView().id(2).frame(width: UIScreen.main.bounds.width)
FourthStepView().id(3).frame(width: UIScreen.main.bounds.width)
}
}.disabled(true)
.animation(
Animation.easeOut(duration: 1)
)
}
.onChange(of: myId, perform: { value in
withAnimation{scrolling.scrollTo(myId)}
})
}
}
question from:https://stackoverflow.com/questions/65844048/disable-the-scrolling-but-not-the-content