0

I have a form with 2 buttons. Now I would like to have a little space between these two buttons. Exactly like in this example: enter image description here

Does anyone know how to implement this? I appreciate any help!

1

1 Answer 1

0

Try with my below code to achieve your exact output.

In the init method TableView sectionHeaderHeight is set to .zero

I have added one button to the section and added an empty title to set dummy space.

struct ContentView: View {
    
    init() {
        UITableView.appearance().sectionHeaderHeight = .zero
    }
    
    var body: some View {
        Form {
            Section {
                HStack {
                    Text("Zeit:")
                        .fontWeight(.semibold)
                    
                    Spacer()
                    
                    Text("Zeit:")
                        .fontWeight(.semibold)
                }
                
                DatePicker(selection: .constant(Date())) {
                    Text("Erstellt:")
                        .fontWeight(.semibold)
                }
            }
            
            Section(header: Text("")) {
                Button {
                } label: {
                    HStack {
                        Spacer()
                        
                        Text("Teilen")
                        
                        Spacer()
                    }
                }
            }
            
            Button {
                
            } label: {
                HStack {
                    Spacer()
                    
                    Text("Löschen")
                    
                    Spacer()
                }
            }
            .tint(.red)
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Output:

enter image description here

Replace the above code and try with that...!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.