How to change the text and background color of a UIDocumentInteractionController Done button

How do I change the background color and text color of the Finish button? Is there a way to change the color of the navigation bar and the color of the title of the navigation bar and the lower color of the bar? Attached screenshot for reference: enter image description here

+5
source share
7 answers

I solved it. Here is the code that works great for me:

func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController { UINavigationBar.appearance().barTintColor = Colors.redColor() UINavigationBar.appearance().tintColor = UIColor.white UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white, NSFontAttributeName: UIFont.systemFont(ofSize: 14, weight: UIFontWeightBold)] return self } 
+1
source

This is a bit of a hack since it relies on the QLPreviewController to be a class that implements the UIDocumentInteractionController, but something like this is the least intrusive solution. Do this before displaying the UIDocumentInteractionController

 import QuickLook UIBarButtonItem.appearance(whenContainedInInstancesOf [QLPreviewController.self]).tintColor = UIColor.black 
+1
source

I have the ability to change the color of the panel:

 let allNavigationBar = UINavigationBar.appearance() allNavigationBar.barTintColor = UIColor.red // change the bar background color allNavigationBar.tintColor = UIColor.black // change the Done button tintColor let alloolbar = UIToolbar.appearance() allToolbar.barTintColor = UIColor.red // dones't work, try backgroundImage allToolbar.backgroundColor = UIColor.blue // dones't work allToolbar.tintColor = UIColor.brown // change the toolbar item tint color 

but this method has a big effect, all your UINavigationBar and UIToolBar will make this change.

Hope anyone else can give a better solution.

0
source

You can temporarily change the color of the hue of the window.

 func presentDocument() { //present the controller here self.appDelegate.window.tintColor = UIColor.red } 

Then change it later:

 func documentInteractionControllerDidEndPreview(documentInteractionController) { //replace parameter with your uidocumentviewinteractioncontroller self.appDelegate.window.tintColor = UIColor.white } 
0
source

@Dee. I think you asked this part in one of your other questions. In this case, you could not show this preview controller. In this question, the suggested answer is to return the self from this delegate method. If you implement this correctly, your preview will use the same color of the navigation bar as its parent controller. I mean, if you opened the UIDocumentInteractionController directly from any ViewController, then the UIDocumentInteractionController will use its parent color for the viewController control panel. This can help you change the color of the Done button.

0
source

Try this: (You need to implement a UIDocumentInteractionControllerDelegate)

 func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController { return self.navigationController ?? self } 
0
source
  let QLNavAppearance = UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]) QLNavAppearance.tintColor = UIColor.red // some QLNavAppearance.barTintColor = UIColor.red // some QLNavAppearance.backgroundColor = UIColor.red // some 
-1
source

Source: https://habr.com/ru/post/1264923/


All Articles