How to embedd QuickLook files inside a view macOS

40 Views Asked by At

This is for a macOS app, here's my code for previewing PDF files using Quicklook:

import Quicklook
struct ContentView: View {

    @State var url: URL?
    var body: some View {
        VStack {


            Button("Open"){
               showOpenPanel()


            }.quickLookPreview($url)

        }
        .padding()
    }
    func showOpenPanel() {
         let openPanel = NSOpenPanel()
         openPanel.allowedFileTypes = ["pdf"]
         openPanel.allowsMultipleSelection = false
         openPanel.canChooseDirectories = false
         openPanel.canChooseFiles = true
         openPanel.runModal()
        url = openPanel.url
     }


}

enter image description here

How do I have the quicklook preview file be shown inside my content view instead of launching itself in a separate window?

0

There are 0 best solutions below