小编Chr*_*is 的帖子

如何在 swift 中将图标添加到共享表中?

我在我的 iOS 应用程序中使用共享表。我想弄清楚如何在它打开时将图标添加到它的左上角。我添加了一个照片示例来说明我的意思。

[我的意思的示例照片][1]

    @IBAction func shareButtonClicked(_ sender: Any) {

        //Set the default sharing message.
        let message = "Check out Num8r, Its so much fun!"
        let link = NSURL(string: "https://apps.apple.com/us/app/num8r/id1497392799")

        // Screenshot:
        UIGraphicsBeginImageContextWithOptions(self.view.frame.size, true, 0.0)
        self.view.drawHierarchy(in: self.view.frame, afterScreenUpdates: false)
        let img = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()

        //Set the link, message, image to share.
        if let link = link, let img = img {
            let objectsToShare = [message,link,img] as [Any]
            let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
            activityVC.excludedActivityTypes = [UIActivity.ActivityType.airDrop, UIActivity.ActivityType.addToReadingList]
            self.present(activityVC, animated: …
Run Code Online (Sandbox Code Playgroud)

xcode swift ios-sharesheet

5
推荐指数
1
解决办法
4612
查看次数

标签 统计

ios-sharesheet ×1

swift ×1

xcode ×1