实例方法
full
fullScreenCover(isPresented:onDismiss:content:)
当绑定到您提供的布尔值为 true 时,呈现一个覆盖尽可能多的屏幕的模式视图。
声明
func fullScreenCover<Content>(
isPresented: Binding<Bool>,
onDismiss: (() -> Void)? = nil,
content: @escaping () -> Content
) -> some View where Content : View
参数
isPresented
与确定是否显示工作表的布尔值的绑定。
onDismiss
关闭模态视图时要执行的关闭。
content
返回模态视图内容的闭包。
详述
使用此方法显示尽可能多地覆盖屏幕的模态视图。下面的示例在用户切换 isPresenting
绑定的值时显示自定义视图:
struct FullScreenCoverPresentedOnDismiss: View {
@State private var isPresenting = false
var body: some View {
Button("Present Full-Screen Cover") {
isPresenting.toggle()
}
.fullScreenCover(isPresented: $isPresenting,
onDismiss: didDismiss) {
VStack {
Text("A full-screen modal view.")
.font(.title)
Text("Tap to Dismiss")
}
.onTapGesture {
isPresenting.toggle()
}
.foregroundColor(.white)
.frame(maxWidth: .infinity,
maxHeight: .infinity)
.background(Color.blue)
.ignoresSafeArea(edges: .all)
}
}
func didDismiss() {
// Handle the dismissing action.
}
}
可用版本
iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, tvOS 14.0+, watchOS 7.0+
相关用法
- Swift Never fullScreenCover(item:onDismiss:content:)用法及代码示例
- Swift Never flipsForRightToLeftLayoutDirection(_:)用法及代码示例
- Swift Never fixedSize()用法及代码示例
- Swift Never focused(_:)用法及代码示例
- Swift Never foregroundStyle(_:)用法及代码示例
- Swift Never focusSection()用法及代码示例
- Swift Never font(_:)用法及代码示例
- Swift Never focused(_:equals:)用法及代码示例
- Swift Never fixedSize(horizontal:vertical:)用法及代码示例
- Swift Never focusedSceneValue(_:_:)用法及代码示例
- Swift Never frame(width:height:alignment:)用法及代码示例
- 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 position(x:y:)用法及代码示例
- Swift Never position(_:)用法及代码示例
- Swift Never luminanceToAlpha()用法及代码示例
- Swift Never accessibilityAction(_:_:)用法及代码示例
- Swift Never previewDisplayName(_:)用法及代码示例
- Swift Never badge(_:)用法及代码示例
- Swift Never progressViewStyle(_:)用法及代码示例
- Swift Never buttonStyle(_:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 Never fullScreenCover(isPresented:onDismiss:content:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。