通过 UIActivityViewController 与 WhatsApp 共享时按钮中的文本颜色错误

2024-04-28

当我与 WhatsApp 分享短信时UIActivityViewController就我而言,共享的第二个屏幕的按钮颜色错误。 第一屏就OK了。这个问题已经讨论过很多次了,可以在这里找到很多答案:当从 iOS7 中的 UIActivityViewController 呈现时,无法设置邮件编辑器中“发送”和“取消”按钮的文本颜色 https://stackoverflow.com/questions/19368122/cannot-set-text-color-of-send-and-cancel-buttons-in-the-mail-composer-when-prese

答案为我修复了以下按钮的颜色:

  • MFMailComposeViewController
  • 分享时的第一个屏幕 WhatsApp

但由于某种原因,不是第二个。

这修复了第一个屏幕:

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

但即使设置所有 UIBarButtonItems 的外观也不起作用:

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

示例代码不起作用:

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

截图:

  • 第一个屏幕:(确定)
  • 第二个屏幕(不正常)
  • 通过电子邮件分享(确定)

只需尝试更改 UIWindow 的tintColor在你的Appdelegate method didFinishLaunchingWithOptions。然后它将作为默认值自动传递给其所有 UIView 后代。

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

希望对你有帮助。

这也可能是第三方的问题,该第三方将(覆盖)再次设置tintColor。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

通过 UIActivityViewController 与 WhatsApp 共享时按钮中的文本颜色错误 的相关文章

随机推荐