我正在尝试实现一个按钮,该按钮使用“来自Botton的幻灯片”动画呈现另一个场景。
PresentationButton看起来不错,因此我尝试了一下:
import SwiftUI
struct ContentView : View {
    var body: some View {
        NavigationView {
            PresentationButton(destination: Green().frame(width: 1000.0)) {
                Text("Click")
                }.navigationBarTitle(Text("Navigation"))
        }
    }
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
    static var previews: some View {
        Group {
            ContentView()
                .previewDevice("iPhone X")
                .colorScheme(.dark)
            ContentView()
                .colorScheme(.dark)
                .previewDevice("iPad Pro (12.9-inch) (3rd generation)"
            )
        }
    }
}
#endif
我希望绿色视图能够覆盖整个屏幕,并且还希望模式不能“拖动以关闭”。
是否可以在PresentationButton中添加修饰符以使其全屏显示并且不可拖动?
我也尝试过导航按钮,但是:-它不会“从底部滑动”-它在详细信息视图上创建了“后退按钮”,我不希望这样
谢谢!
所以从技术上讲,我想显示一个加载屏幕视图。我正在使用fullScreenCover.
struct ContentView: View {
    
    @State private var isLoading = false
        
    var body: some View {
        VStack {
            Text("Hello there")
            Button("Start loading") {
                isLoading.toggle()
            }
            .fullScreenCover(isPresented: $isLoading) {
                ZStack{
                    Color.black.opacity(0.5).edgesIgnoringSafeArea(.all)
                    VStack {
                        ProgressView()
                        Button("Stop loading") {
                            isLoading.toggle()
                        }
                    }
                }
            }
        }
    }
}
问题是我无法使这个加载屏幕半透明。sheet或popover以同样的方式行事。