实例方法
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:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。