通过 UIActivityViewController 与 WhatsApp 共享时按钮中的文本颜色错误 [英] Wrong text color in buttons when sharing with WhatsApp via UIActivityViewController

本文介绍了通过 UIActivityViewController 与 WhatsApp 共享时按钮中的文本颜色错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 UIActivityViewController 与 WhatsApp 共享文本时,共享的第二个屏幕(就我而言)具有错误的按钮颜色.第一个画面没问题.这个问题已经讨论了很多次,在这里可以找到一大堆答案:

  • 第二个屏幕(不好)

  • 通过电子邮件分享(OK)

解决方案

只需尝试在 Appdelegate 方法中更改 UIWindow 的 tintColor didFinishLaunchingWithOptions.然后它会默认自动传递给它所有的 UIView 后代.

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

希望对您有所帮助.

这也可能是第三方的问题,它会(覆盖)再次设置 tintColor.

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)

解决方案

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.

这篇关于通过 UIActivityViewController 与 WhatsApp 共享时按钮中的文本颜色错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆