如何将图像图标附加到 `UIActivityViewController`?

How to attach an image icon to the `UIActivityViewController`?

如何将图像图标附加到 UIActivityViewController

当我做的时候

    let activityViewController = UIActivityViewController(
          activityItems: [ 
                           UIImage(named: "imageName")!,
                           urlName, 
                           urlProduct
                         ], 
         applicationActivities: nil)

没用

您需要使用 activityViewControllerLinkMetadata 方法定义 LinkMetadata

    @available(iOS 13.0, *)
    func activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) -> LPLinkMetadata? {
        let metadata = LPLinkMetadata()
        // define your metadata here
        return metadata
    }

更多信息在这里:https://developer.apple.com/documentation/uikit/uiactivityitemsource/3144571-activityviewcontrollerlinkmetada?language=swift