Why is the height of Text SwiftUI View different when setting the frame's width vs it's maxWidth when using fixedSize()?

Viewed 83

Why does the height of Text SwiftUI View expand correctly to allow for displaying the content when setting the width but it collapses to a single line when setting the maxWidth of it's frame?

struct ContentView: View {
    var body: some View {
        VStack {
            Text("Long Text Long Text Long Text Long Text Long Text Long Text Long Text Long Text Long Text")
                .background(Color.blue)
            Text("Short Text")
                .background(Color.green)
        }
        // .frame(width: 400) 
        // .frame(maxWidth: 400)
        .fixedSize()
    }
}


struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

with .frame(width: 400):

width[1]

with .frame(maxWidth: 400):

maxWidth

0 Answers
Related