0

Currently, I am wondering how to display alertview or any custom view as an overlay to display a message to the user using SwiftUI.

SwiftUI provided replacement for UIDatepicker with struct DatePicker, is there any similar struct present for UIAlertController?

If no, then how to display View or custom view like an alert view.

I went through couple of WWDC videos and some SwiftUI tutorials but didn't found any view struct that supports alertview behaviour.

Sunil Sharma
  • 2,653
  • 1
  • 25
  • 36

1 Answers1

1

You can use presentation method for alert

var body: some View {
        Text("Placeholder").presentation(.constant(true)) { () -> Alert in
            Alert(title: Text("Title"), message: nil, dismissButton: Alert.Button.cancel())
        }
    }

and for actionSheet too:

Text("").presentation(ActionSheet(title: Text("Placeholder")))
Argas
  • 1,427
  • 1
  • 10
  • 12