I have an app that I would like to implement sharing an Image from a Button within a .contextMenu as below. I’d like to share from the button in the same way as a ShareLink would.
I see other resources suggest the use of the UIActivityViewController although I was wondering if there is a SwiftUI approach that would not involve UIKit.
.contextMenu {
Button(action: {
debugPrint("Share")
}) {
Label("Share", systemImage: "square.and.arrow.up")
}
}
It appears that the ShareLink can be added, alongside other buttons, within the .contextMenu as below.
.contextMenu {
Button(action: {
debugPrint("Share")
}) {
Label("Share", systemImage: "square.and.arrow.up")
}
ShareLink(item: image, preview: SharePreview("image", image: image)) {
Label("Share", systemImage: "square.and.arrow.up")
}
}