實例方法
sheet(is
sheet(isPresented:onDismiss:content:)
當與您提供的布爾值的綁定為真時顯示工作表。
聲明
func sheet<Content>(
isPresented: Binding<Bool>,
onDismiss: (() -> Void)? = nil,
content: @escaping () -> Content
) -> some View where Content : View
參數
isPresented
與布爾值的綁定,該值確定是否顯示您在修改器的
content
閉包中創建的工作表。onDismiss
關閉工作表時要執行的關閉。
content
返回工作表內容的閉包。
詳述
當您提供的布爾值為真時,如果您想向用戶呈現模式視圖,請使用此方法。當用戶通過單擊或點擊 “Show License Agreement” 按鈕來切換 isShowingSheet
變量時,以下示例顯示了軟件許可協議模型的模式視圖:
struct ShowLicenseAgreement: View {
@State private var isShowingSheet = false
var body: some View {
Button(action: {
isShowingSheet.toggle()
}) {
Text("Show License Agreement")
}
.sheet(isPresented: $isShowingSheet,
onDismiss: didDismiss) {
VStack {
Text("License Agreement")
.font(.title)
.padding(50)
Text("""
Terms and conditions go here.
""")
.padding(50)
Button("Dismiss",
action: { isShowingSheet.toggle() })
}
}
}
func didDismiss() {
// Handle the dismissing action.
}
}
可用版本
iOS 13.0+, iPadOS 13.0+, macOS 10.15+, Mac Catalyst 13.0+, tvOS 13.0+, watchOS 6.0+
相關用法
- Swift Never sheet(item:onDismiss:content:)用法及代碼示例
- Swift Never shadow(color:radius:x:y:)用法及代碼示例
- Swift Never saturation(_:)用法及代碼示例
- Swift Never simultaneousGesture(_:including:)用法及代碼示例
- Swift Never symbolVariant(_:)用法及代碼示例
- Swift Never scaledToFill()用法及代碼示例
- Swift Never safeAreaInset(edge:alignment:spacing:content:)用法及代碼示例
- Swift Never searchCompletion(_:)用法及代碼示例
- Swift Never submitScope(_:)用法及代碼示例
- Swift Never scaleEffect(x:y:anchor:)用法及代碼示例
- Swift Never speechAlwaysIncludesPunctuation(_:)用法及代碼示例
- Swift Never submitLabel(_:)用法及代碼示例
- Swift Never scaleEffect(_:anchor:)用法及代碼示例
- Swift Never scaledToFit()用法及代碼示例
- Swift Never swipeActions(edge:allowsFullSwipe:content:)用法及代碼示例
- Swift Never suggestedFileName(_:)用法及代碼示例
- Swift Never scenePadding(_:)用法及代碼示例
- Swift Never pageCommand(value:in:step:)用法及代碼示例
- Swift Never opacity(_:)用法及代碼示例
- Swift Never colorMultiply(_:)用法及代碼示例
- Swift Never accessibilityAction(action:label:)用法及代碼示例
- Swift Never alert(isPresented:error:actions:message:)用法及代碼示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:actions:)用法及代碼示例
- Swift Never flipsForRightToLeftLayoutDirection(_:)用法及代碼示例
- Swift Never position(x:y:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Never sheet(isPresented:onDismiss:content:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。