Last active
May 10, 2020 04:27
-
-
Save asingh33/eb8ef2ec5df194b7ccb0fa1153efebac to your computer and use it in GitHub Desktop.
Create a UIView subclass wrapper for PDFView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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