swiftuiios-navigationview

Padding between Navigation Links in a Form, in Swift UI


I want to setup a form in SwiftUI and I want to make a spacing between two Navigation Links in a Form. Like thisThis is the spacing I mean

I have no Idea how to do this (I have tried it with .padding, two different forms use.) Thanks Boothosh


Solution

  • These are Sections inside a Form. No need for padding, just use default spacing with Sections. Here is an example

    struct ContentView: View {
        @State var username: String = ""
        @State var password: String = ""
        
        var body: some View {
            NavigationView {
                Form {
                    Section {
                        TextField("Username", text: $username)
                    }
                    Section {
                        TextField("Password", text: $password)
                    }
                }
                .navigationBarTitle("Settings")
            }
        }
    }