Wrong text color in buttons when sharing with WhatsApp via UIActivityViewController

萝らか妹 提交于 2020-08-05 18:45:50

问题


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:

  • MFMailComposeViewController
  • And the first screen when sharing to WhatsApp

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:

  • First screen: (OK)

  • Second screen (not OK)

  • Share by e-mail (OK)


回答1:


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.



来源:https://stackoverflow.com/questions/44650061/wrong-text-color-in-buttons-when-sharing-with-whatsapp-via-uiactivityviewcontrol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!