Hi everyone,
I’m trying to customise look of the QLPreviewController.
Problem is it’s not default look of it, because global appearance of UINavigationBar, UIBarButtonItem, UITabBar are changed in app delegate.
To change tint color of navigation bar I subclassed QLPreviewController and in viewDidLoad() did this:
self.navigationController?.navigationBar.tintColor = nil
It comes back to default blue color. This is how it looks right now and what I would like to change.
I tried to change barTintColor same as I changed back button tint color but it didn’t worked.
This is how I’m opening QLPreviewController
viewController.pushViewController(self, animated: true)
import Foundation
import QuickLook
class DocumentPreviewer: QLPreviewController, QLPreviewControllerDataSource, QLPreviewControllerDelegate {
var fileURL: URL?
override func viewDidLoad() {
self.navigationController?.navigationBar.tintColor = nil
}
func openDocument(vc: UIViewController, document: Document?) {
guard let document = document else {
print("Cannot open document because it's nil")
return
}
if let navController = vc.navigationController {
navController.pushViewController(self, animated: true)
} else {
vc.show(self, sender: nil)
}
API.sharedInstance.fetchDocument(document) { (saved) in
DispatchQueue.main.async(execute: {
guard let url = saved else {
print("File url is not valid")
return
}
if QLPreviewController.canPreview(url as QLPreviewItem) {
self.currentPreviewItemIndex = 0
self.fileURL = url
self.dataSource = self
self.delegate = self
self.reloadData()
} else {
makeDefaultAlert(self, title: "Not supported", msg: "File is not supported for preview")
print("Item not supported by QLPreviewController")
}
})
}
}
func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
return 1
}
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
return fileURL as! QLPreviewItem
}
}
And this is how I’m calling it
let docpreview = DocumentPreviewer()
docpreview.openDocument(vc: self, document: document)
Thanks for help,
Najdan
