0

I am presenting activity controller as below:

let vc = UIActivityViewController(activityItems: [SettingsProvider.shareUrl], applicationActivities: nil)
vc.modalTransitionStyle = .crossDissolve
vc.modalPresentationStyle = .overCurrentContext
self.present(vc, animated: true, completion: nil)

Also, I have set global tint color for the navigation bar, window tint color using appearance property.

When I click application such as message app, the controller takes app tint color for bar buttons except for MFMailViewController. Is there any way to change tint colour of presented applications of UIActivityController.

Changing BarButton appearance would create a problem for my app. Any other solutions are appreciated.

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50
cgeek
  • 558
  • 5
  • 18

2 Answers2

2

I have found a solution but don't know if this is right way.

Writing an extension to MFMailComposeViewController saved me.

extension MFMailComposeViewController: MFMailComposeViewControllerDelegate {
    open override func viewDidLoad() {
        super.viewDidLoad()
        navigationBar.tintColor = UIColor.white
    }
}

MFMailComposeViewController presented through Activity controller will correspond to extension I have written. In this way, MFMailComposeViewController will respond to overridden viewDidLoad() method.

Syscall
  • 19,327
  • 10
  • 37
  • 52
cgeek
  • 558
  • 5
  • 18
0

please try this code for changing bar button color I think it will help you.

var navigationBarAppearace = UINavigationBar.appearance()
navigationBarAppearace.tintColor = uicolorFromHex(0xffffff)
navigationBarAppearace.barTintColor = uicolorFromHex(0x034517)

OR

please use this code I have use this code in objective c.

MFMailComposeViewController* mailViewController = [[MFMailComposeViewController alloc] init];        
mailViewController.mailComposeDelegate = self;
[mailViewController setToRecipients:@[@"abc@def.com"]];

[mailViewController.navigationBar setTintColor:[UIColor blackColor]];

[self presentViewController:mailViewController animated:YES completion:nil]; 
Bhumesh Purohit
  • 491
  • 1
  • 8
  • 26
  • I have already set this in appDelegate. I have a problem with presented MFMailComposeViewController of UIActivityViewController. – cgeek Dec 14 '17 at 11:30
  • I have tried this but not working.facing same issue. – Vishal Dec 14 '17 at 11:59
  • I have Update my Code please refer. @cgeek – Bhumesh Purohit Dec 14 '17 at 12:25
  • I am presenting UIActivityViewController through which I get to open several applications such as mail or message apps. I don't have direct access to mail. Your code is used to present mail view controller. – cgeek Dec 14 '17 at 13:20
  • I have found solution. I have posted in answers section. – cgeek Apr 13 '18 at 03:54