Laying white toolbar over QLPreviewController toolbar is looking gray

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 18:01:07

问题


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.


回答1:


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
    }

}


来源:https://stackoverflow.com/questions/41107566/laying-white-toolbar-over-qlpreviewcontroller-toolbar-is-looking-gray

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!