0

I am changing a project colors and this old orange color not changed on UIActivityViewController button. I want to change button color orange to white. This look is when user press the share button and select "Add to Notes" button. How can I access these buttons and change colors?

Add to Notes Screen

First problem solved. This code is working on buttons:

UIButton.appearance(whenContainedInInstancesOf: [UINavigationBar.self]).tintColor = .white

When I click to "New Note" this look is came. How can I change the title color on this view? I want to change this title color black to white.

enter image description here

This is my sharing code and I was trying every bar tint color code.

func shareLink(_ link: String) {
    let activityViewController = UIActivityViewController(activityItems: [link], applicationActivities: nil)

    activityViewController.navigationController?.navigationBar.barTintColor = .white
    activityViewController.navigationController?.navigationBar.tintColor = .white
    activityViewController.tabBarController?.navigationItem.backBarButtonItem?.tintColor = .white
    activityViewController.tabBarController?.navigationController?.navigationBar.tintColor = .white

    self.present(activityViewController, animated: true)
}

Also I tried adding some code on AppDelegate in didFinishLaunchingWithOptions function

UINavigationBar.appearance().tintColor = .white
UIApplication.shared.keyWindow?.tintColor = .white
Hilalkah
  • 945
  • 15
  • 37
  • @KSigWyatt No, it's not possible. I don't know where I can access this button and I ask it. – Hilalkah May 28 '19 at 14:02
  • 1
    Did you try something like this? https://stackoverflow.com/a/47060512/6448167 – KSigWyatt May 28 '19 at 14:10
  • @KSigWyatt No, I didn't try. It worked, but I asked how I could access those buttons. – Hilalkah May 28 '19 at 14:15
  • 1
    These buttons are not accessible. Apple generates the buttons within this controller based on the localization of the client device. As https://stackoverflow.com/a/15294107/6448167 this answer suggests you may be able to override and generate your own `UIActivityViewController` in order to change / access the contents of the buttons in the controller's navigation bar. – KSigWyatt May 28 '19 at 14:21
  • @KSigWyatt Ok. Thanks, but when i click to "New Note" some black title came. How can I change color too? – Hilalkah May 28 '19 at 14:34

1 Answers1

0

Ok. These buttons are not accessible. So I solved the problem as follows:

It's for all UINavigationBar buttons:

UIButton.appearance(whenContainedInInstancesOf: [UINavigationBar.self]).tintColor = .white

It's for all UINavigationBar titles:

UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
Hilalkah
  • 945
  • 15
  • 37