1

enter image description hereI simply added TextLabel in scrollview but it is displaying in 1 line only. Without scrollview it is working fine with full height of 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)
        }
    }
Rock
  • 1,408
  • 1
  • 12
  • 27
  • Possible duplicate of [How do you create a multi-line text inside a ScrollView in SwiftUI?](https://stackoverflow.com/questions/56593120/how-do-you-create-a-multi-line-text-inside-a-scrollview-in-swiftui) – superpuccio Sep 06 '19 at 14:59

1 Answers1

5

Try .fixedSize modifier after your 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)

...
Mehdi
  • 1,192
  • 1
  • 9
  • 21