Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a UIView subclass wrapper for PDFView
// This struct will return pdfView in UIView form to make it SwiftUI compatible
struct PDFViewUI : UIViewRepresentable {
var url: URL?
init(url : URL) {
self.url = url
}
func makeUIView(context: Context) -> UIView {
let pdfView = PDFView()
if let url = url {
pdfView.document = PDFDocument(url: url)
}
return pdfView
}
func updateUIView(_ uiView: UIView, context: Context) {
// Empty
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment