0
votes

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
1
@KSigWyatt No, it's not possible. I don't know where I can access this button and I ask it.Hilalkah
Did you try something like this? stackoverflow.com/a/47060512/6448167KSigWyatt
@KSigWyatt No, I didn't try. It worked, but I asked how I could access those buttons.Hilalkah
These buttons are not accessible. Apple generates the buttons within this controller based on the localization of the client device. As 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
@KSigWyatt Ok. Thanks, but when i click to "New Note" some black title came. How can I change color too?Hilalkah

1 Answers

0
votes

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]