Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios QLPreviewController';第一次打开时,其颜色不同_Ios_Swift_User Interface_Uinavigationbar_Qlpreviewcontroller - Fatal编程技术网

Ios QLPreviewController';第一次打开时,其颜色不同

Ios QLPreviewController';第一次打开时,其颜色不同,ios,swift,user-interface,uinavigationbar,qlpreviewcontroller,Ios,Swift,User Interface,Uinavigationbar,Qlpreviewcontroller,每当我打开qlviewcontroller时,tintColor默认为粉红色。我希望它是一种特定的颜色,所以我就这样设置它 UINavigationBar.appearance().tintColor = UIColor.hexStringToUIColor(hexStr: "202020") 这就是调出qlviewcontroller的方法的样子 func openQLPreview() { quickLookController = QLPreviewController()

每当我打开
qlviewcontroller
时,
tintColor
默认为粉红色。我希望它是一种特定的颜色,所以我就这样设置它

UINavigationBar.appearance().tintColor = UIColor.hexStringToUIColor(hexStr: "202020")
这就是调出
qlviewcontroller
的方法的样子

func openQLPreview() {
    quickLookController = QLPreviewController()
    UINavigationBar.appearance().tintColor = UIColor.hexStringToUIColor(hexStr: "202020")
    quickLookController.dataSource = self
    self.navigationController?.pushViewController(self.quickLookController, animated: true)
}

我希望它始终是第二种颜色,无论它是否是我第一次调用
qlviewcontroller
。每当应用程序终止并重新启动时,它就会切换回粉红色

编辑(2/12/19) 我已经解决了。它不起作用的原因是,在将
QLPreviewController
推送到
navigationController
堆栈之前,我正在设置tintColor,因此,它正在为堆栈中的上一个navigationItem设置
tintColor
(这算不了什么,因为我在整个应用程序中使用了自定义的
导航栏
)。因此,当
QLPreviewController
从堆栈中弹出,然后在下次打开文档时推回时,
tintColor
仍保留在我上次设置它时的状态

func openQLPreview() {
    quickLookController = QLPreviewController()
    quickLookController.dataSource = self
    self.navigationController?.pushViewController(self.quickLookController, animated: true)
    UINavigationBar.appearance().tintColor = UIColor.hexStringToUIColor(hexStr: "202020")
}
因此,只需使用
UINavigationBar.appearance().tintColor
在推送
qlviewController
后设置tintColor,即可解决此问题。

尝试此操作

@IBOutlet weak var m_NavBar: UINavigationBar!

func openQLPreview() 
{
    quickLookController = QLPreviewController()
    m_NavBar.appearance().tintColor = UIColor.hexStringToUIColor(hexStr: "202020")
    quickLookController.dataSource = self
    self.navigationController?.pushViewController(self.quickLookController, animated: true)
}

我没有将IB用于QLPreviewController或导航栏;tt是以编程方式完成的。