UIActivityViewController共享消息取消未显示

时间:2017-11-21 16:08:20

标签: ios swift3 ios11 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")
            }
        }

1 个答案:

答案 0 :(得分:0)

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

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