ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • SwiftUI에서 Modal을 Present하기
    카테고리 없음 2021. 2. 8. 01:47
    import SwiftUI
    
    struct ContentView: View {
        @State private var isPresented = false
    
        var body: some View {
            Button("Present!") {
                self.isPresented.toggle()
            }
            .fullScreenCover(isPresented: $isPresented, content: FullScreenModalView.init)
        }
    }
    
    struct FullScreenModalView: View {
        @Environment(\.presentationMode) var presentationMode
    
        var body: some View {
            VStack {
                Text("This is a modal view")
            }
            .frame(maxWidth: .infinity, maxHeight: .infinity)
            .background(Color.red)
            .edgesIgnoringSafeArea(.all)
            .onTapGesture {
                presentationMode.wrappedValue.dismiss()
            }
        }
    }
    

    Ch11. Navigation에서 다루지 않길래

    댓글 0

Designed by Tistory.