SwiftUIModalView 0.0.2

SwiftUIModalView 0.0.2

由以下人员维护:HereTrix.



  • HereTrix

ModalNavigationView

将模态展示实现为SwiftUI

如何使用

步骤 1

使用Swift Package Manager将依赖添加到您的项目中:https://github.com/HereTrix/ModalView

步骤 2

导入依赖

import SwiftUIModalView

步骤 3

像使用NavigationView和NavigationLink一样使用ModalNavigationViewModalNavigationLink

struct ContentView: View {
    var body: some View {
        ModalNavigationView {
            ModalNavigationLink(destination: SheetDetails(),
                                completion: {
            }) {
                Text("Show over current context")
            }
        }
    }
}

或者使用.sheet

struct ContentView: View {

    @State var isPresenting = false

    var body: some View {
        Button(action: {
            self.isPresenting = true
        }) {
            Text("Modal with fullscreen")
                .present(isPresented: $isPresenting,
                     style: .fullScreen) { Text("Fullscreen presentation") }
        }
    }
}

更多信息

查看示例应用程序以获取更多详细说明