Skip to content

Instantly share code, notes, and snippets.

@navsing
Created September 11, 2020 18:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navsing/d0efe47ce06abd68c134fb4fee1811e0 to your computer and use it in GitHub Desktop.
Save navsing/d0efe47ce06abd68c134fb4fee1811e0 to your computer and use it in GitHub Desktop.
import SwiftUI
import PlaygroundSupport
struct Screen: View {
@State var show = false
@State var items: [Any] = []
var body: some View {
VStack {
Button(action: {
self.items.removeAll()
self.items.append(UIImage(named: "886F0165-77FA-4778-8E50-8DD24B230839.jpg"))
self.show.toggle()
}) {
Text("Share")
}.sheet(isPresented: $show) {
ShareSheetView(items: self.items).edgesIgnoringSafeArea(.all)
}
}
}
}
struct ShareSheetView: UIViewControllerRepresentable {
let items: [Any]
func makeUIViewController(context: Context) -> some UIActivityViewController {
return UIActivityViewController(activityItems: items, applicationActivities: nil)
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
}
}
PlaygroundPage.current.setLiveView(Screen())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment