если у вас есть primaryButton, вам нужно предоставить вторичную кнопку. Этот код здесь работает и должен ответить на ваш вопрос:
import SwiftUI
struct ContentView: View {
@State var showsAlert = false
@State var errorMsg = "xxxx"
var body: some View {
Button(action: { self.showsAlert = true }) {
Text("press to test").padding(10).border(Color.black)
}.alert(isPresented: self.$showsAlert) {
Alert(title: Text(self.errorMsg),
message: Text("text message"),
primaryButton: Alert.Button.default(Text("yes"), action: {
print("---> yes")
}),
secondaryButton: Alert.Button.default(Text("no"), action: {
print("---> no")
}))
}
}
}