在SwiftUI,SwiftUI中调整多个vstack宽度

问题描述

我有一个VStack

VStack(alignment: .leading) {
        Text(question)
            .fontWeight(.heavy)
            .font(.system(.footnote,design: .rounded))
            .padding(.bottom)
        Text(answer)
            .fontWeight(.semibold)
            .font(.system(.title,design: .rounded))
    }
    .padding(35)
    .overlay(RoundedRectangle(cornerRadius: 12).stroke(Color("darkGrey"),lineWidth: 2))
    .padding([.leading,.top,.trailing])
    .frame(minWidth: UIScreen.main.bounds.width - 5,minHeight: 50,maxHeight: .infinity,alignment: .topLeading
    )

我在View中使用它,例如:

ScrollView(.horizontal,showsIndicators: false) {
                Group {
                    HStack {
                        questionCard(question: "Cats or Dogs",answer: "Dogs")
                        questionCard(question: "Cats or Dogs",answer: "Dogs")
                    }
                }
            }

结果如下:

enter image description here

我试图将框的width移到屏幕的末尾(具有.trailing的空格),然后当我滚动到下一个时,它的宽度应该相同。 / p>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)