ShareView
ShareView is a SwiftUI wrapper for
UIActivityViewController that enables external sharing
capabilities. This wrapper carries over success, failure and destination
metadata through the
UIActivityViewController.CompletionWithItemsHandler, which
is not available in the SwiftUI native ShareLink as of iOS
17.
Usage
ShareView(
shareableItems: [
Shareable.Image(
image: {
let renderer = ImageRenderer(
content: Rectangle()
.fill(.orange)
.frame(width: 100, height: 100)
)
return renderer.uiImage!
}(),
title: "Test Image"
)
]
)
.ignoresSafeArea()
.presentationDetents([.medium, .large])Features
- Supports external image sharing by passing Shareable.Image.
- Supports external video sharing by passing Shareable.Video.
- Supports usage in SwiftUI Previews for easy debugging and testing.