Skip to content

Instantly share code, notes, and snippets.

@asingh33
Last active May 10, 2020 04:27
Show Gist options
  • Save asingh33/eb8ef2ec5df194b7ccb0fa1153efebac to your computer and use it in GitHub Desktop.
Save asingh33/eb8ef2ec5df194b7ccb0fa1153efebac to your computer and use it in GitHub Desktop.
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