How do I make an toggle button inside an alert in swiftUI

77 Views Asked by At

I want to show a toggle button inside alert

.alert(
    Text("Create"),
    isPresented: $showCreate
) {
    Button("Cancel", role: .cancel) {

    }
    Button("Enter") {
       //some function
    }
    TextField("Name", text: $Name)
    TextField("Key (Optional)", text: $Key)
    .keyboardType(.numberPad)
    Toggle("permanent", isOn: $isPermanent)
} message: {
    Text("Please enter details.")
}

it shows toggle as button named "permanent" in between cancel and enter button

0

There are 0 best solutions below