cgeek
cgeek

Reputation: 578

MFMailComposeViewController in UIActivityViewController has default blue tint colour

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.

Upvotes: 0

Views: 467

Answers (2)

cgeek
cgeek

Reputation: 578

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.

Upvotes: 2

Bhumesh Purohit
Bhumesh Purohit

Reputation: 499

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:@[@"[email protected]"]];

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

[self presentViewController:mailViewController animated:YES completion:nil]; 

Upvotes: 0

Related Questions