Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show full text in scroll view in Swift UI

Tags:

ios

swift

swiftui

I'm writing view that should contain multiline text, I use scroll view to scroll it, but it also wraps my text. Modifiers like .lineLimit(nil) doesn't work.

var body: some View {
    ScrollView{
        Text(lesson.text)
    }
}

So it is screenshots without and with scroll view.

without scroll view

with scroll view

like image 405
Daniel Paleyev Avatar asked Nov 02 '19 20:11

Daniel Paleyev


1 Answers

var body: some View {
    ScrollView{
        Text(lesson.text)
            .fixedSize(horizontal: false, vertical: true)
    }
}

should solve the problem.

This is default in iOS 13.1 and above.

like image 175
Rudrank Riyam Avatar answered Sep 28 '22 09:09

Rudrank Riyam