實例方法
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:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。