swiftuitabbarcontrolleruinavigationbaruiactivityviewcontrollertintcolor

UIActivityViewController: access the navigation items to change color of presented view


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

Solution

  • 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]