A binding to a Boolean value that determines whether to present the alert that you create in the modifier’s content
closure. When the user presses or taps OK the system sets is
to false
which dismisses the alert.
Instance Method
インスタンスメソッド
alert(is
alert(isPresented:content:)
Presents an alert to the user.
アラートをユーザに提示します。
Availability 有効性
- iOS 13.0–15.4 Deprecated
- iPadOS 13.0–15.4 Deprecated
- macOS 10.15+
- Mac Catalyst 13.0–15.4 Deprecated
- tvOS 13.0+
- watchOS 6.0+
Technology
- Swift
UI
Declaration 宣言
Parameters パラメータ
isPresented
Presented content
A closure returning the alert to present. 提示するアラートを返しているあるクロージャ。
Discussion 議論
Use this method when you need to show an alert to the user. The example below displays an alert that is shown when the user toggles a Boolean value that controls the presentation of the alert:
struct OrderCompleteAlert: View {
private var isPresented = false
var body: some View {
Button("Show Alert", action: {
isPresented = true
})
.alert(isPresented: $isPresented) {
Alert(title: Text("Order Complete"),
message: Text("Thank you for shopping with us."),
dismissButton: .default(Text("OK")))
}
}
}