Fast and Lean PDF Viewer for iPhone / iPad / iOS - tips and hints?

后端 未结 3 788
攒了一身酷
攒了一身酷 2020-11-22 06:47

There has been many Questions recently about drawing PDF\'s.

Yes, you can render PDF\'s very easily with a UIWebView but this cant give the performance

3条回答
  •  清歌不尽
    2020-11-22 07:18

    Since iOS 11, you can use the native framework called PDFKit for displaying and manipulating PDFs.

    After importing PDFKit, you should initialize a PDFView with a local or a remote URL and display it in your view.

    if let url = Bundle.main.url(forResource: "example", withExtension: "pdf") {
        let pdfView = PDFView(frame: view.frame)
        pdfView.document = PDFDocument(url: url)
        view.addSubview(pdfView)
    }
    

    Read more about PDFKit in the Apple Developer documentation.

提交回复
热议问题