文本标签未根据 ScrollView SwiftUI 中的字符串展开

Roc*_*ock 0 ios swift swiftui

在此处输入图片说明我只是在滚动视图中添加了 TextLabel,但它仅显示在 1 行中。没有滚动视图,它可以在 Label 的全高度下正常工作

 struct UserDetailView: View {

        var userObj:User?

        var body: some View {
            ScrollView {
                VStack {

                    Text("Hi here is Erick jackson. We need to help you. We will help you. Anything new to learn from you. I am here for that reason.")
                        .background(Color.orange)
                        .multilineTextAlignment(.center)
                    .lineLimit(5)
                }
            }
            .padding(.horizontal,30)
        }
    }
Run Code Online (Sandbox Code Playgroud)

Meh*_*hdi 5

.fixedSize在您之后尝试修改器Text("Hi here is Erick Jackson....")

...

Text("Hi here is Erick jackson. We need to help you. We will help you. Anything new to learn from you. I am here for that reason.")
.fixedSize(horizontal: false, vertical: true)

.background(Color.orange)

...
Run Code Online (Sandbox Code Playgroud)