【发布时间】:2020-10-08 00:31:05
【问题描述】:
【问题讨论】:
标签: swiftui
【问题讨论】:
标签: swiftui
这是默认的.sheet 行为。
使用 SwiftUI 2.0 改为使用全屏覆盖
@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *)
@available(macOS, unavailable)
extension View {
/// Presents a modal view that covers as much of the screen as
/// possible using the given item as a data source for the sheet's content.
///
/// - Parameters:
/// - item: A binding to an optional source of truth for the cover
/// modal view. When representing a non-nil item, the system uses
/// `content` to create a modal representation of the item.
/// If the identity of `item` changes, the system will dismiss a
/// currently-presented modal view and replace it by a new modal view.
/// - onDismiss: A closure executed when the modal view dismisses.
/// - content: A closure returning the content of the modal view.
public func fullScreenCover<Item, Content>(item: Binding<Item?>, onDismiss: (() -> Void)? = nil, @ViewBuilder content: @escaping (Item) -> Content) -> some View where Item : Identifiable, Content : View
/// Presents a modal view that covers as much of the screen as
/// possible when a given condition is true.
///
/// - Parameters:
/// - isPresented: A binding to whether the modal view is presented.
/// - onDismiss: A closure executed when the modal view dismisses.
/// - content: A closure returning the content of the modal view.
public func fullScreenCover<Content>(isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil, @ViewBuilder content: @escaping () -> Content) -> some View where Content : View
}
对于 SwiftUI 1.0,您可以使用过渡来全屏显示您的视图,请参阅 https://stackoverflow.com/a/61446820/12299030 中的示例
【讨论】: