更改 UIActivityViewController 中 UIBarButtonItems 的色调颜色

MJQ*_*347 5 ios uiactivityviewcontroller swift

我有一个导航栏,在深色背景颜色上使用白色色调。我用来UIActivityViewController分享 iOS 分享表的链接。

当我选择 WhatsApp 或消息应用程序共享内容时,导航按钮具有默认的蓝色色调。此外,搜索栏(以 WhatsApp 为例)具有灰色色调,这确实使其难以阅读。

我无法更改色调颜色。我的代码:

let textToShare = "Visit my website!"
if let myWebsite = NSURL(string: "http://google.com") {
    let objectsToShare = [textToShare, myWebsite]
    let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)

    self.presentViewController(activityVC, animated: true, completion: {
        activityVC.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
        activityVC.navigationController?.navigationItem.rightBarButtonItem?.tintColor = UIColor.whiteColor()   
        activityVC.navigationController?.navigationItem.leftBarButtonItem?.tintColor = UIColor.whiteColor()
    })
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

编辑:

这不是重复的问题,因为它与活动视图控制器的按钮色调颜色无关。它与视图控制器的导航控制器的按钮颜色有关,例如按下 iMessage 上的共享后显示的按钮颜色。

W D*_*son 1

您可以通过在应用程序委托的 UIWindow 实例上设置tintColor 来设置 UIActivityViewController 呈现的视图控制器的tintColor。无论何时或如何设置,在 UIActivityViewController 上设置tintColor似乎都没有效果。

在您的应用程序委托中:

    self.window.tintColor = [theme navBarItemsTintColor];
Run Code Online (Sandbox Code Playgroud)