首页 > 解决方案 > hstack 中的组可以让 vstack spacer() 出错,任何人都可以告诉我为什么

问题描述

我的代码:

ScrollView(.horizontal, showsIndicators: false){
            VStack{
                HStack{
                    VStack(alignment:.leading){
                        Text("monday,aug 2010".uppercased())
                            .font(.caption)
                        Text("your reading".capitalized)
                            .font(.title)
                            .fontWeight(.bold)
                        
                    }
                    .padding([.top, .leading, .trailing])
                    Spacer()
                }
                
                HStack(alignment:.center){
                    Group{
                        CardView(image: "swiftui-button", category: "SwiftUI", heading: "Drawing a Border with Rounded Corners", author: "Simon Ng")
                        CardView(image: "macos-programming", category: "macOS", heading: "Building a Simple Editing APP", author: "Gabriel Theodoropoulos")
                        CardView(image: "flutter-app", category: "Flutter", heading: "Building a complex app with flutter", author: "Lawrence Tan")
                        CardView(image: "natural-language-api", category: "ios", heading: "What's New  in Natural Language API", author: "Sai kambampati")
                    }.frame(width:300)
                }
                Spacer()
            }
        }

myQuestion:VStack(alignment:.leading) 位于中心,而不是前导,如果我删除 group{},它可以工作,但是如果我将 group 添加到 hstack,是错误的,我认为这是一个有趣的错误,你能想到出来?

标签: swiftui

解决方案


推荐阅读