Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 447

How to display a List or Table without empty rows at bottom?

$
0
0

I'm looking for a way to display a SwiftUI Table or List at its "intrinsic size" without including empty rows or empty space below the rows, as it does in the following example, in which the table is given a blue border for clarity:

Example

It is generated by the following code:

struct ContentView: View {    let names = ["Achmed", "Balthus", "Chaim"]    var body: some View {        VStack {            Text("List of Names")                .font(.largeTitle)                .padding()            List(names, id: \.self) { Text($0) }                .border(.blue)                .padding()            Spacer()        }    }}

I would like the Spacer() to reduce the height of the List, removing the extra space inside the List View below its last row - but it does not.

Nor does adding .fixedSize() modifier. (I wonder why the list doesn't have an idealHeight that does not include empty rows, such that adding .fixedSize() would cause it to be displayed that way.)


Viewing all articles
Browse latest Browse all 447

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>