Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change UIDocumentInteractionController Done button text and background color

How to change the background color and text color of done button? Is there a way that I can change the navigationbar color and navigation bar title color and bottom bar color also? Attached screenshot for reference: enter image description here

like image 531
Dee Avatar asked Mar 02 '17 07:03

Dee


3 Answers

I solved it. Here is the code working for me perfectly:

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
}
like image 130
Saurabh Shukla Avatar answered Nov 15 '22 22:11

Saurabh Shukla


I have a idear to change the bar color:

let allNavigationBar = UINavigationBar.appearance()
allNavigationBar.barTintColor = UIColor.red  // change the bar background color
allNavigationBar.tintColor = UIColor.black // change the Done button's 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's item tint color

but this method has a great effect,all your UINavigationBarand UIToolBar will make that change.

Hope anyone else can give a better solusion.

like image 24
Guan Avatar answered Nov 15 '22 21:11

Guan


It's a little hacky as its relying on the fact that QLPreviewController is the class implementing the UIDocumentInteractionController but something like this is the least intrusive solution. Do it before you display the UIDocumentInteractionController

import QuickLook

UIBarButtonItem.appearance(whenContainedInInstancesOf [QLPreviewController.self]).tintColor = UIColor.black
like image 2
user3065306 Avatar answered Nov 15 '22 21:11

user3065306