Sjoerd Perfors
Sjoerd Perfors

Reputation: 2317

Wrong text color in buttons when sharing with WhatsApp via UIActivityViewController

When I share an text to WhatsApp with the UIActivityViewController the second screen of the sharing, for my case, has the wrong button colors. The first screen is OK. This issue has been discussed a lot of times and one great bucket of answers can be found here: Cannot set text color of Send and Cancel buttons in the mail composer when presented from the UIActivityViewController in iOS7

The answer fixes for me the button colors of:

But for some reason not the second one.

This did the fix for the first screen:

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]];

But even setting the appearance of all UIBarButtonItems is not working:

[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];

Example code not working:

self.window?.tintColor = UIColor.white
let activityController = UIActivityViewController.init(activityItems: items, applicationActivities: nil)

if let vc = delegate?.currentViewController() {
    sender.isEnabled = false
    
    vc.present(activityController, animated: true, completion: {
        sender.isEnabled = true
    })
    activityController.navigationController?.navigationBar.tintColor = UIColor.white
    activityController.view.tintColor = UIColor.white

Screenshots:

Whatsapp first screen (OK)

Whatsapp second screen (NOT OK)

Email (OK)

Upvotes: 2

Views: 518

Answers (1)

Piyush Mathur
Piyush Mathur

Reputation: 1607

Just try by changing the UIWindow's tintColor in your Appdelegate method didFinishLaunchingWithOptions. It will then automatically pass as default to all its UIView descendants.

[self.window setTintColor:[UIColor whiteColor]];

Hope this will help you.

It could also be an issue with the third party which would be (overriding) setting the tintColor again.

Upvotes: 1

Related Questions