Make SwiftUI Form wrap contents properly

Viewed 318

Swift 5.1
There's a View that contains a Form. When I put that View in any other View, the Form takes up way more space than it needs. For example:

VStack {
    Form {
        Text("Form")
    }
    Text("Not form")
    Text("Also not form")
}

This results in the entire screen being taken up by the Form (containing only the one Text), save for the two Text squashed way down at the bottom. How do I get Form to shrink-wrap to the size of its contents? .frame(height: 100) (from https://stackoverflow.com/a/59635380/513038) vaguely works, but you have to know how big the contents are, beforehand, which isn't always the case.

0 Answers
Related