OGeek|极客世界-中国程序员成长平台

标题: ios - UIActivityViewController 分享消息取消不显示 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:20
标题: ios - UIActivityViewController 分享消息取消不显示

当我想通过 UIActivityViewController 与消息应用程序共享 URL 时。取消按钮是白色的(我猜是因为它仍然可以点击)

它只出现在 iOS 11 上,这里的代码用于呈现 UIActivityViewController,我已经尝试在呈现 UIActivityViewController 之前更改颜色,但按钮保持白色:

if #available(iOS 11.0, *) {
   UIButton.appearance(whenContainedInInstancesOf:[UINavigationController.self]).tintColor = .blue
}

这里是用来展示 UIActivityViewController 的代码

let vc = UIActivityViewController(activityItems: [article.webReference], applicationActivities: [])
        self.present(vc, animated: false, completion:nil)

        vc.completionWithItemsHandler = {(s, ok, items, error) in
            switch s {
            case UIActivityType.mail?:
                print("mail")
                AnalyticsHelper.sharedInstance.sendShareMailEvent(articleUrl: article.webReference)
            case UIActivityType.postToFacebook?:
                print("facebook")
                AnalyticsHelper.sharedInstance.sendShareFacebookEvent(articleUrl: article.webReference)
            case UIActivityType.postToTwitter?:
                print("twitter")
                AnalyticsHelper.sharedInstance.sendShareTwitterEvent(articleUrl: article.webReference)
            default:
                print("others")
            }
        }



Best Answer-推荐答案


由于 UIBarButtomItem.apperance().tintColor 更改,我遇到了同样的问题。我没有更改默认 UI 外观,而是创建了从 UINavigationController 继承的 NavigationController 类,并在 viewDidLoad 方法中自定义了我需要的内容。接下来,我将 Storyboard和纯代码中使用的所有 UInavigationController 更改为 NavigationController。现在我可以在 AppDelegate 中更改这个类的控件,例如:

let navBarButton = UIBarButtonItem.appearance(whenContainedInInstancesOf: [NavigationController.self])
navBarButton.tintColor = .white

关于ios - UIActivityViewController 分享消息取消不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47417573/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4