實例方法
full
fullScreenCover(item:onDismiss:content:)
使用您提供的綁定作為工作表內容的數據源,呈現一個覆蓋盡可能多的屏幕的模式視圖。
聲明
func fullScreenCover<Item, Content>(
item: Binding<Item?>,
onDismiss: (() -> Void)? = nil,
content: @escaping (Item) -> Content
) -> some View where Item : Identifiable, Content : View
參數
item
綁定到工作表的可選事實來源。當
item
不是nil
時,係統會將內容傳遞給修飾符的閉包。您在係統向用戶顯示的您創建的工作表中顯示此內容。如果item
更改,係統將關閉當前顯示的工作表並使用相同的過程將其替換為新工作表。onDismiss
關閉模態視圖時要執行的關閉。
content
返回模態視圖內容的閉包。
詳述
使用此方法可顯示盡可能多地覆蓋屏幕的模態視圖。在下麵的示例中,自定義結構 - CoverData
- 為全屏視圖提供數據,以在用戶單擊或點擊“Present Full-Screen Cover With Data”按鈕時顯示在 content
閉包中:
struct FullScreenCoverItemOnDismissContent: View {
@State var coverData: CoverData?
var body: some View {
Button("Present Full-Screen Cover With Data") {
coverData = CoverData(body: "Custom Data")
}
.fullScreenCover(item: $coverData,
onDismiss: didDismiss) { details in
VStack(spacing: 20) {
Text("\(details.body)")
}
.onTapGesture {
coverData = nil
}
}
}
func didDismiss() {
// Handle the dismissing action.
}
}
struct CoverData: Identifiable {
var id: String {
return body
}
let body: String
}
可用版本
iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, tvOS 14.0+, watchOS 7.0+
相關用法
- Swift Never fullScreenCover(isPresented: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(item:onDismiss:content:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。