I have implemented share button in Swift using following code:
@IBAction func share(_ sender: UIBarButtonItem) {
let textToShare = [ "Text to share" ]
let activityViewController = UIActivityViewController(activityItems: textToShare, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash
self.present(activityViewController, animated: true, completion: nil)
}
Everything seems working but when I share content through message then the cancel button is missing from text composing to return back if I change my mind sharing it.
Change navigation bar tint color in your app using below code:
in AppDelegate
didFinishLaunchingWithOptions
UINavigationBar.appearance().tintColor = UIColor.red
replace red with color that you want to set in button.