SwiftUI | VStack won’t work inside of ForEach Loops

It works with small fix – added explicit parameter for ForEach. Tested with Xcode 12.1 / iOS 14.1

demo

HStack {
    ForEach(0 ..< 7) { i in
        VStack {
            Capsule().frame(width: 30, height: 200)
            Text("\(i + 1)")
        }
    }
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top