1

I am using the following code to create a horizontal scroll view with negative spacing (I'm using negative spacing so the items in the stack overlap). Whenever my app is in a small window and I interact with the scroll view's slider, the app crashes with a Thread 1: EXC_BAD_INSTRUCTION (code=EXC_1386_INVOP,subcode=0x0) error. Is this a known issue or is there a more correct way to implement this design?

var body: some View {
    GeometryReader { geometry in
        ScrollView(.horizontal) {
            HStack(spacing: -20) {
                ForEach(Array(elements.enumerated()), id: \.offset) { index, element in
                    Text(element.text).zIndex(Double(index))
                }
            }.frame(minWidth: geometry.size.width)
        }
    }
}
2
  • 1
    please add whts inside ForEach Commented Dec 26, 2020 at 4:29
  • Works fine with Xcode 12.1 / macOS 10.15.7. Which env did you use? Commented Dec 26, 2020 at 7:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.