Transition to UIDocumentInteractionController takes over navigation bar title color

183 views Asked by At

Just doing a simple transition a UIDocumentInteractionController to display a PDF. Its title is black, which is desired, but I want it to go back to the app color (white) when it goes back. Trying to force a change in viewWillAppear does nothing (though I do see viewWillAppear is being called). I also tried changing the color in documentInteractionControllerDidEndPreview but again nothing happens. The color stays black. Using the following to change the color:

let textAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
self.navigationController?.navigationBar.largeTitleTextAttributes = textAttributes

Giving the UIDocumentInteractionController the navigation controller:

open func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
        guard let vc = self.navigationController else {
            fatalError("No navigation controller")
        }
        return vc
}

How can i have a black title when presenting the document and white (or whatever color I desire) when i go back? This should be something simple but ive been going in circles.

1

There are 1 answers

0
thesuffering On BEST ANSWER
let navBarAppearance = UINavigationBarAppearance()
    navBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
    navBarAppearance.backgroundColor = .clear
    self.navigationController?.navigationBar.standardAppearance = navBarAppearance

Calling this in viewDidLoad fixed the problem