我如何在自己的应用程序中像 Safari 一样分享 url

How can i share a url like Safari do in my own app

我想分享一个 url 就像 Safari 在我自己的 iOS 应用程序中所做的那样,我该怎么做? 使用socail框架可以在一些指定的社交平台上分享,但在我的情况下,我只想像Safari一样分享url。

你觉得UIActivityViewController怎么样?

@IBAction func shareTextButton(_ sender: UIButton) {

    // image to share
    let link = "https://www.google.rs/"

    // set up activity view controller
    let activityViewController = UIActivityViewController(activityItems: [link], applicationActivities: nil)
    activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash

    // exclude some activity types from the list (optional)
    activityViewController.excludedActivityTypes = [ UIActivityType.airDrop, UIActivityType.postToFacebook ]

    // present the view controller
    self.present(activityViewController, animated: true, completion: nil)


}