当我使用 UIActivityViewController
向 WhatsApp 分享文本时,就我而言,分享的第二个屏幕的按钮颜色错误。
第一屏就OK了。这个问题已经被讨论了很多次,可以在这里找到一大堆答案:Cannot set text color of Send and Cancel buttons in the mail composer when presented from the UIActivityViewController in iOS7
答案为我修复了以下按钮的颜色:
- 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
屏幕截图:
- 第一个屏幕:(确定)
- 第二个屏幕(不正常)
- 通过电子邮件共享(确定)
最佳答案
只需尝试在 Appdelegate
方法 didFinishLaunchingWithOptions
中更改 UIWindow 的 tintColor
。然后它将默认自动传递给它的所有 UIView 后代。
[self.window setTintColor:[UIColor whiteColor]];
希望对您有所帮助。
这也可能是第三方的问题,第三方会(覆盖)再次设置 tintColor。
关于ios - 通过 UIActivityViewController 与 WhatsApp 共享时按钮中的文本颜色错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44650061/