0

The tintColor whenever I bring up the QLPreviewController is pink by default. I wanted it to be a specific color so I set it like so

UINavigationBar.appearance().tintColor = UIColor.hexStringToUIColor(hexStr: "202020")

This is what the method that brings up the QLPreviewController looks like

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

This is what it looks like the first time (after installing or closing and re-opening I open a document using the QLPreviewController

And this is what it looks like when I tap the back arrow and open the same document or any other document

I want it to be the second color at all times, regardless of whether it is my first time calling QLPreviewController or not. It switches back to the pink whenever the app is terminated and re-launched.

Edit (2/12/19) I have solved it. The reason it wasn't working because I was setting the tintColor before the QLPreviewController was pushed onto the navigationController stack therefore, it was setting the tintColor for the previous navigationItem in the stack (which is nothing because I am using a custom navigationBar throughout my app). So when QLPreviewController gets popped off the stack, and then pushed back in the next time I open a document, the tintColor remains from when I last set it.

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

Therefore, simply setting the tintColor using UINavigationBar.appearance().tintColor after QLPreviewController has been pushed, fixed the issue.

ashvin10
  • 73
  • 7

1 Answers1

0

try this

@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)
}