I'm attempting to view a PDF using QLPreviewController and I'm struggling to change some of the view attributes such as Navigation Bar header and the background of the view.
I was able to change the translucency of the Navigation Bar after subclassing QLPreviewController and changing the self.navigationController.navigationBar.translucency = NO;
in the didViewAppear
method, however I am unable to make changes to the navigationBar.title
or the backgroundColor
attributes of the self.view.backgroundColor
.
Both the title and the background color will flicker when the view first loads but are immediately superseded by the PDF title string and the PDF itself which overlays the background color of the view. The PDF pages appear over a black background.
I want to first know IF it's possible to subclass or otherwise change that background color to my own custom color, then I would love to know if anyone has any suggestions or know a decent solution to changing that background color.
The same goes for the title value to a lesser extent.
In Swift 4 subclass UINavigationController and put in it:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]).isTranslucent = false
UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]).tintColor = #colorLiteral(red: 0.1889409125, green: 0.6918108463, blue: 0.9730117917, alpha: 1)
UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]).titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With