0

I was trying to implement vertical scroll with image and text but I am not able to achieve it.

I tried on both Xcode beta 1 & 2. Here is the code snippet

1

1 Answer 1

1

Try to wrap both the Text and the Image in a VStack and be sure that there is enough content inside the ScrollView to fall outside it's bounds (in the right direction - vertically in your case):

ScrollView {
    VStack {
        ForEach (1...100) {_ in
            Image(systemName: "circle.fill")
            Text("my text")
        }
    }
}

You could easily try it out in a Playground like this :

import SwiftUI
import PlaygroundSupport

struct LiveView : View {
    var body: some View {
        ScrollView {
            VStack {
                ForEach (1...100) {_ in
                    Image(systemName: "circle.fill")
                    Text("Some text")
                }
            }
        }
    }
}

PlaygroundPage.current.liveView = UIHostingController(rootView: LiveView())
Sign up to request clarification or add additional context in comments.

Comments

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.