Swift – UIActivityViewController 原生內建分享 FB/IG/Line 社群分享

Swift怎麼分享文字至FB/IG?

UIActivityViewController是swift用來分享文字或圖片至FB/IG/Line 等社群,這邊注意instagram只能分享圖片,facebook則是分享文字或圖片都可以。

Swift分享文字至FB/IG/Line

let activityViewController = UIActivityViewController(activityItems: ["文字"], applicationActivities: nil)
self.present(activityViewController, animated: true, completion: nil)

Swift分享文字至 FB,Line或是其他社群

Swift分享文字至

Swift分享文字至Line

Swift分享文字至Line

Swift分享文字至FB

Swift分享文字至FB

Swift分享圖片至FB/IG/Line

var activityImage = UIImage(named: "bg_code")
let activityViewController = UIActivityViewController(activityItems: [activityImage, "文字"], applicationActivities: nil)
self.present(activityViewController, animated: true, completion: nil)

Swift分享圖片FB

Swift分享圖片FB

Swift分享圖片IG

Swift分享圖片IG


Categorized in: