Change color of UIDocumentInteractionController action bar button text.

In iOS 10 the share button of the UIDocumentInteractionController is not inside the UINavigationBar. Rather it is now at the footer of the document preview bounds. Example http://i.imgur.com/bUlx5Xq.png. Notice the grey on white share button in the footer?


How do I go about changing the color of the action bar that contains the share button in iOS 10?

Answered by jeremychild in 187436022

I have solved this issue. To get extensibility around the UIDocumentInteractionController you must use the QLPreviewController instead.


Once you have a QLPreviewController setup with the delegates for self and dataSource you can present the controller on to your parent view. The first child of the QLPreviewController (once presented) is the UINavigationController. You can then modify the tint of both the bar and the bottom toolbar.


let previewController = QLPreviewController()
previewController.delegate = self
previewController.dataSource = self

view.present(previewController, animated: false, completion: {
    // Attempt to find the UINavigationController that the QLPreviewController is using to display toolbars and navigation bars
    let firstChild = previewController.childViewControllers[0]
    if (firstChild is UINavigationController) {
     
        let navigationController = firstChild as! UINavigationController
     
        let navigationBar = navigationController.navigationBar
        // The bar must be set isTranslucent = false for the tint colours to work
        navigationBar.isTranslucent = false
        navigationBar.barTintColor = UIColor.blue
        navigationBar.tintColor = UIColor.blue
     
        let toolbar = navigationController.toolbar
        if (toolbar != nil) {
            // The toolbar must be set isTranslucent = false for the tint colours to work
            toolbar!.isTranslucent = false
            toolbar!.barTintColor = UIColor.blue
        }
    }
})
Accepted Answer

I have solved this issue. To get extensibility around the UIDocumentInteractionController you must use the QLPreviewController instead.


Once you have a QLPreviewController setup with the delegates for self and dataSource you can present the controller on to your parent view. The first child of the QLPreviewController (once presented) is the UINavigationController. You can then modify the tint of both the bar and the bottom toolbar.


let previewController = QLPreviewController()
previewController.delegate = self
previewController.dataSource = self

view.present(previewController, animated: false, completion: {
    // Attempt to find the UINavigationController that the QLPreviewController is using to display toolbars and navigation bars
    let firstChild = previewController.childViewControllers[0]
    if (firstChild is UINavigationController) {
     
        let navigationController = firstChild as! UINavigationController
     
        let navigationBar = navigationController.navigationBar
        // The bar must be set isTranslucent = false for the tint colours to work
        navigationBar.isTranslucent = false
        navigationBar.barTintColor = UIColor.blue
        navigationBar.tintColor = UIColor.blue
     
        let toolbar = navigationController.toolbar
        if (toolbar != nil) {
            // The toolbar must be set isTranslucent = false for the tint colours to work
            toolbar!.isTranslucent = false
            toolbar!.barTintColor = UIColor.blue
        }
    }
})
Change color of UIDocumentInteractionController action bar button text.
 
 
Q