「SwiftUI」调用自带分享功能

调用自带分享功能

Posted by Jiaolong on 2021/09/04

Code

func shareApp() {
  var toShare = "准备分享的内容"
  let activityViewController = UIActivityViewController(activityItems: [toShare], applicationActivities: nil)
  let viewController = Coordinator.topViewController()
  activityViewController.popoverPresentationController?.sourceView = viewController?.view
  viewController?.present(activityViewController, animated: true, completion: nil)
}

支持文字、图片等、CSV格式等。