I have a simple List in SwiftUI. Code and Screenshot included below. I would like to reduce the height of each row in the list (so less space between lines and text lines closer
Use Environment variable to set min Height of the row in the list and after that change the HStack frame height to your desired height.
Here is the code:
var body: some View {
VStack {
Text("Pressure Readings")
.font(.system(size: 30))
List(pressureList) { row in
HStack {
Spacer()
Text(row.timeStamp)
Text("--->")
Text(String(row.pressureVal))
Spacer()
}.frame(height: 10)
}.environment(\.defaultMinListRowHeight, 10)
}
}
Here is the output: