如何防止图纸在SwiftUI中使其后面的视图变暗或删除不必要的填充?

如何防止图纸在SwiftUI中使其后面的视图变暗或删除不必要的填充?,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 tha


显示图纸(模式)时,其后面的视图会收缩并变暗,从而在图纸后面形成一个灰色矩形(请参见图片中红色框内的位)。如何防止背景中的视图变暗,或在其缩小时去除其周围的白色填充?

这是默认的
.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

}
@可用(iOS 14.0、tvOS 14.0、watchOS 7.0、*)
@可用(macOS,不可用)
扩展视图{
///显示一个模式视图,尽可能多地覆盖屏幕
///可能使用给定项作为工作表内容的数据源。
///
///-参数:
///-项目:与封面可选真实来源的绑定
///模式视图。表示非零项时,系统使用
///`content`创建项目的模态表示。
///如果'item'的标识发生变化,系统将关闭
///当前显示的模态视图,并将其替换为新的模态视图。
///-onDismiss:当模态视图解除时执行的闭包。
///-content:返回模态视图内容的闭包。
public func fullScreenCover(项目:绑定,onDismiss:(()->Void)?=nil,@ViewBuilder内容:@escaping(项目)->内容)->某些视图,其中项目:可识别,内容:视图
///显示一个模式视图,尽可能多地覆盖屏幕
///当给定条件为真时可能。
///
///-参数:
///-isPresented:是否显示模式视图的绑定。
///-onDismiss:当模态视图解除时执行的闭包。
///-content:返回模态视图内容的闭包。
public func fullScreenCover(显示:Binding,onDismiss:(()->Void)?=nil,@ViewBuilder content:@escaping()->content)->某些视图,其中content:View
}

对于SwiftUI 1.0您可以使用transition全屏显示您的视图,请参见中的示例感谢您的快速响应!那么,您是说除非工作表全屏显示,否则无法修改此默认行为?