func actionSheet <T>(item: Binding<T?>, content: (T) -> ActionSheet ) -> some View
func alert(isPresented : Binding<Bool>, content: () -> Alert) -> some View
func alert<Item>(item: Binding<Item?>, content: (Item) -> Alert) -> some View
Deprecated 非推奨
Availability 有効性
Technology
func actionSheet(isPresented: Binding
<Bool
>, content: () -> ActionSheet
) -> some View
isPresented
A binding to a Boolean value that determines whether to present the action sheet that you create in the modifier’s content
closure. When the user presses or taps the sheet’s default action button the system sets this value to false
dismissing the sheet.
content
A closure returning the Action
to present.
提示するAction
を返しているあるクロージャ。
In the example below, a button conditionally presents an action sheet depending upon the value of a bound Boolean variable. When the Boolean value is set to true
, the system displays an action sheet with both destructive and default actions:
struct ConfirmEraseItems: View {
private var isShowingSheet = false
var body: some View {
Button("Show Action Sheet", action: {
isShowingSheet = true
})
.actionSheet(isPresented: $isShowingSheet) {
ActionSheet(
title: Text("Permanently erase the items in the Trash?"),
message: Text("You can't undo this action."),
buttons:[
.destructive(Text("Empty Trash"),
action: emptyTrashAction),
.cancel()
]
)}
}
func emptyTrashAction() {
// Handle empty trash action.
}
}
Note 注意
In regular size classes in iOS, the system renders alert sheets as a popover that the user dismisses by tapping anywhere outside the popover, rather than displaying the default dismiss button.
func actionSheet <T>(item: Binding<T?>, content: (T) -> ActionSheet ) -> some View
func alert(isPresented : Binding<Bool>, content: () -> Alert) -> some View
func alert<Item>(item: Binding<Item?>, content: (Item) -> Alert) -> some View