通过UIActivityViewController与Whatsapp共享时,按钮中的textColor错误

时间:2017-06-20 10:08:02

标签: ios uinavigationbar uiactivityviewcontroller mfmailcomposeviewcontroller uiappearance

当我使用UIActivityViewController与Whatsapp共享文本时,共享的第二个屏幕的按钮颜色错误。第一个屏幕没问题。这个问题已经讨论了很多次,可以在这里找到一大堆答案: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

截图:

第一个屏幕(OK) Whatsapp first screen (OK) 第二个屏幕(不行) Whatsapp second screen (NOT OK) 通过电子邮件分享(好) Email (OK)

1 个答案:

答案 0 :(得分:1)

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

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

希望这会对你有所帮助。

这也可能是第三方的一个问题,即(重写)再次设置tintColor。

相关问题