我在我的 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)