0

我想为水平视图中的社交媒体图标制作滚动视图,以便缩放和调整大小,使其看起来像这张图片

- 我应该使用滚动视图还是列表视图?也以水平方式

我已经尝试过这段代码,但它没有用,你有什么我可能错过的解决方案吗?

struct ContentView: View {
    var body: some View {
        NavigationView {
            VStack(alignment: .leading, spacing: 20){
            Text("Total number of posts we've analyzed so for : 35.513.682")
                .frame(width: 300, height: 50, alignment: .topLeading)
                .padding()
                .background(Color(#colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)))
                .cornerRadius(15)
                .multilineTextAlignment(.leading)
                Spacer()
                    .frame(height: 5)
                
                Text("Which social media do you generate hashtags for?")
                    .multilineTextAlignment(.leading)
                    
                            
               Spacer()
                
                //Scroll view
                ScrollView(.horizontal, showsIndicators: false){
                    HStack(spacing: 20){
                        ForEach(0..<10){ index in
                            Image( "facebook")
                            Image( "instagram")
                            Image( "flickr ")
                            Image( "google-plus")
                            Image( "linkedin")
                            Image( "pinterest")
                            Image( "tik-tok")
                            Image( "tumblr")

                        }
                        
                        .frame(width: 100, height: 100, alignment: .center)
                        .padding()
                    }//hs
                    
                   

                }
                    
                    
      
            
            
            }//vs
            .navigationTitle(Text("Hashtags"))
        
    }// NV
}
}
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            ContentView()
                .preferredColorScheme(.dark)
                .previewDevice("iPhone 11")
        
        }
    }
}
4

0 回答 0