0

does anyone have an idea how can i break Vertical ScrollView into small horizontal ScrollView using SwiftUi:

I have the code bellow which displays the youtubeResults vertically, since each item of the ForEach is smaller, so i want to group them by 3 itens Horizontally , then the following 3 itens goes bellow them vertically until the forEach ends.

I would like the results to be displayed like that(with images, this is just an example):

(Justin beiber) (Drake) (Omarion)

(Mandela) (Dj Khaled) (Nirvana)

(Justin beiber) (Prince) (Adele)

My code: Displaying the results one by one Vertically

 ScrollView (.vertical, showsIndicators: false, content:{
                    
                    LazyVStack(spacing : 25){
                        
                        ForEach(getData.youtubeResults){ result in
                            
                            SideItemView(youtubeResults: result, selectedTheme: self.$selectedTheme)
                        }
                    }
                    .padding()
                    .padding(.top)
                })
1
  • 2
    Don't you want to use LazyVGrid instead? Commented Oct 30, 2020 at 11:16

1 Answer 1

1

As stated by Asperi, LazyVGrid or LazyHGrid was the soulution, introduced by Apple in IOS 14+.

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.