Can i put multiple text lines in a single list section in SwiftUI?

Jake :

I want to put multiple lines of text in one section of a list (before the first divider). The issue being any new text added gets its own new line.

Is there any way for me to put multiple lines in one list section? Here's my code:

struct ChestWorkouts: View {
@State var BPWeight: String = ""
@State var GoalBPWeight: String = ""
var body: some View {
    List{
        Text("Bench Press").fontWeight(.bold)
        TextField("Goal Weight", text: $GoalBPWeight).keyboardType(.numberPad)
        TextField("Weight", text: $BPWeight).keyboardType(.numberPad)

    }.environment(\.defaultMinListRowHeight, 90)
Mac3n :

You can put them in a VStack

struct ContentView: View {
    @State var BPWeight: String = ""
    @State var GoalBPWeight: String = ""
    var body: some View {
        List{
            VStack {
                Text("Bench Press").fontWeight(.bold)
                TextField("Goal Weight", text: $GoalBPWeight).keyboardType(.numberPad)
                TextField("Weight", text: $BPWeight).keyboardType(.numberPad)
            }
        }.environment(\.defaultMinListRowHeight, 90)
    }
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=383367&siteId=1
Recommended