I am using PDFView (Representable) in a SwiftUI project to display documents that are black text on a white background.
When in dark mode I want to be able to invert the colors so they appear as white text on a black background.
I don't see any way to change the text color or page color in the PDFView so was wonding if there is any other way I can get the entire view to just invert it's colors?
struct PDFKitView: UIViewRepresentable {
let uRL: URL
init(_ uRL: URL) {
self.uRL = uRL
}
func makeUIView(context: UIViewRepresentableContext<PDFKitView>) -> PDFKitView.UIViewType {
let pdfView = PDFView()
pdfView.document = PDFDocument(url: self.uRL)
pdfView.autoScales = true
pdfView.displayMode = .singlePage
pdfView.displayDirection = .horizontal
pdfView.usePageViewController(true)
pdfView.tintColor = .red
return pdfView
}
func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<PDFKitView>) {
}
}
struct ContentView: View {
var body: some View {
let url = Bundle.main.url(forResource: "example", withExtension: "pdf")!
PDFKitView(url)
}
}