With a Button
I can directly copy contents to the clipboard via UIPasteboard.general.setObjects(objects)
, but this is iOS-specific so I was hoping that ShareLink
would allow me to share items in a platform-independent way. Is it possible to show a Copy item in the ShareLink
sheet?
import SwiftUI
struct ContentView: View {
let myType = MyType()
var body: some View {
ShareLink(item: myType, preview: SharePreview(myType.text))
}
}
class MyType: Transferable {
let text = "asdf"
static var transferRepresentation: some TransferRepresentation {
ProxyRepresentation { myType in
return myType.text
}
}
}
#Preview {
ContentView()
}