在 SwiftUI VStack 中,如何制作多个文本视图,每个视图都有多行文本,宽度相同

问题描述

我正在尝试使 vstack 中的文本具有相同的宽度,但不知道如何操作。我在其他地方看到有人建议将每个文本视图的框架 maxWidth 设置为 .infinity,但在我的代码中尝试时它没有任何效果

这是我的代码

struct ContentView: View {
    var body: some View {
        vstack(alignment: .center,spacing: 8.0) {
            Spacer()
            Text("Youngsters can play in Kids mode. If you're feeling very adventurous you can play in BigKids mode.")
                .padding(.horizontal)
            Text("Kids mode uses large images and big differences between the number of images shown.")
                .padding(.horizontal)
            Text("BigKids mode,on the other hand,uses small images and small differences between the number of images shown. Go for it!")
                .padding(.horizontal)
            Spacer()
        }
        .frame(maxWidth: 600.0)
    }
}

我为 vstack 使用的框架 maxWidth 为 600,因为我不希望它比使用 iPad 时更宽。

这是代码的结果。请注意,每个文本视图的宽度都不同。

Results of the code

解决方法

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

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

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...