5

I am sharing a text using UIActivityViewController, And on choosing "Message" from the options listed my screen appears as follows, enter image description here

But there is a cancel button at right bar button which is white color as assigned in my AppDelegate.
The problem here is I cannot able to update NavigationBar color.

I have tried as follows and none was useful,

let activityVC = UIActivityViewController(activityItems: contents, applicationActivities: nil)
    present(activityVC, animated: true) {
        activityVC.navigationController?.navigationBar.backgroundColor = UIColor.green
        activityVC.navigationController?.navigationBar.tintColor = UIColor.red
        MYAppDelegate.customise()
    }

or

let activityVC = UIActivityViewController(activityItems: contents, applicationActivities: nil)
    present(activityVC, animated: true) { 
        UINavigationBar.appearance().barTintColor = UIColor.red
        UINavigationBar.appearance().tintColor = UIColor.white
        let navigationTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
        UINavigationBar.appearance().titleTextAttributes = navigationTextAttributes
        UIBarButtonItem.appearance().setTitleTextAttributes(navigationTextAttributes, for: .normal)
        UIBarButtonItem.appearance().tintColor = UIColor.white
    }

How to resolve this issue ?

Bharath
  • 2,064
  • 1
  • 14
  • 39

1 Answers1

0

What you are trying to do is sharing some content thru share extension[1](what you showed in the picture) of iOS message app which is developed by Apple. So basically Apple has control on the color of it.

Here is a link of my previous answer: https://stackoverflow.com/a/42517419/5220959 I haven't tried yet but I think you can try to change the UIAppearance settings of your host app and see if that works. But in that way all navigation bars' color will be changed in your host app.

[1]https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Share.html#

Community
  • 1
  • 1
jokeman
  • 1,277
  • 9
  • 22