When I want to share a URL with the message application via the UIActivityViewController
. The cancel button is white (I guess because it still tappable)
It only appears on iOS 11, here the code use to present the UIActivityViewController and I already tried to change the color before presenting the UIActivityViewController
but the button stay white :
if #available(iOS 11.0, *) {
UIButton.appearance(whenContainedInInstancesOf:[UINavigationController.self]).tintColor = .blue
}
Here the code used to present the 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")
}
}
I had a same problem because of UIBarButtomItem.apperance().tintColor changed. Instead of changing default UI look I created my class of NavigationController which inherits from UINavigationController and in viewDidLoad method I have customise what I need. Next I changed all UInavigationController uses in storyboard and pure code to NavigationController. And now I can change controls for this class in AppDelegate, for example:
let navBarButton = UIBarButtonItem.appearance(whenContainedInInstancesOf: [NavigationController.self])
navBarButton.tintColor = .white