danielsaidi / DeckKit

DeckKit is a Swift SDK that helps you build deck-based apps in SwiftUI.
MIT License
653 stars 14 forks source link

Questions about sharing #3

Closed sy1995 closed 2 years ago

sy1995 commented 2 years ago

How is the sharing effect in the example picture realized? Is there any relevant code?

thx!

danielsaidi commented 2 years ago

Hi! The sharing is done by first taking a snapshot if the view, then sharing it with a share sheet.

I think the demo app has this functionality built in, otherwise you can find both the View+Snapshot extension and the ShareSheet implementation in my SwiftUIKit library:

https://github.com/danielsaidi/SwiftUIKit

danielsaidi commented 2 years ago

Hi again,

Closing this due to inactivity.

Just wanted to add that SwiftUI 4 now contains an ImageRenderer that can be used to take snapshots of views. If your app supports older iOS versions, you can find a backported version in SwiftUIKit:

https://github.com/danielsaidi/SwiftUIKit