I stumbled upon this SO discussion on adding/removing qlpreviewcontroller's uibarbuttonitems. However they were removing the navigation bar and overlaying a new one on top of it.
I was looking to change the toolbar primarily because the toolbar that comes with QLPreviewController is black and the rest of the toolbars in my application are white.
I have code in place to get the bar overlaying but it seems that when I set the toolbar tint color to white, its actually becoming a light gray. I was thinking that this was because the toolbar was not opaque but after setting alpha to 1.0 it still looks the same.
Relevant toolbar code from class extending QLPreviewController
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
....
self.overlayToolBar?.setItems([actionBtn], animated: false)
self.overlayToolBar?.tintColor = .blue
self.overlayToolBar?.barTintColor = .white
}
Toolbar from previous screen
Toolbar from QLPreviewController screen
Original Toolbar for QLPreviewController
Is there a different/better way to set the toolbar color? Since QuickLook runs through XPC I can't edit the toolbar directly. Thus I have to do this roundabout hack to get a customized toolbar on the screen.
I ran into a similar issue when I was attempting to not show all of the items on a QLPreviewController.
I ended up subclassing the QLPreviewController:
import QuickLook
class PreviewController: QLPreviewController {
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
navigationItem.leftBarButtonItems = nil
}
}