在QLPreviewController上放置白色工具栏看起来是灰色 [英] Laying white toolbar over QLPreviewController toolbar is looking gray
问题描述
我偶然发现了关于添加/删除qlpreviewcontroller的uibarbuttonitems的SO讨论.但是,他们正在删除导航栏,并在其上方叠加了一个新的导航栏.
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.
我之所以要更改工具栏,主要是因为QLPreviewController附带的工具栏是黑色的,而应用程序中其余的工具栏是白色的.
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.
我有适当的代码来覆盖条形图,但是当我将工具栏的颜色设置为白色时,它实际上变成了浅灰色.我以为这是因为工具栏不是不透明的,但是将alpha设置为1.0后,它仍然看起来一样.
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.
扩展了QLPreviewController的类中的相关工具栏代码
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
....
self.overlayToolBar?.setItems([actionBtn], animated: false)
self.overlayToolBar?.tintColor = .blue
self.overlayToolBar?.barTintColor = .white
}
上一屏幕上的工具栏
QLPreviewController屏幕上的工具栏
QLPreviewController的原始工具栏
是否有其他/更好的方法来设置工具栏颜色?由于QuickLook在XPC中运行,因此我无法直接编辑工具栏.因此,我必须绕过 hack 来在屏幕上获得自定义的工具栏.
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.
推荐答案
当我尝试不显示QLPreviewController上的所有项目时,我遇到了类似的问题.
I ran into a similar issue when I was attempting to not show all of the items on a QLPreviewController.
我最终继承了QLPreviewController的子类:
I ended up subclassing the QLPreviewController:
import QuickLook
class PreviewController: QLPreviewController {
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
navigationItem.leftBarButtonItems = nil
}
}
这篇关于在QLPreviewController上放置白色工具栏看起来是灰色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!