Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion #1

Open
L1cardo opened this issue Jul 20, 2020 · 2 comments
Open

Discussion #1

L1cardo opened this issue Jul 20, 2020 · 2 comments

Comments

@L1cardo
Copy link

L1cardo commented Jul 20, 2020

I found a way to rasterize views to images directly using a button.

For example:
If you just do this, it will not work. Because the text is ""

@State private var text = ""

Button("rasterize") {
    Text(text).rasterize()
}

But here is the tricky part, you can change the @State text in another view and pass it by @Binding

//first view
@State private var text = ""

Button("rasterize") {
    Text(text).rasterize()
}

// second view
@Binding var text: String

TextField("Change the text here", text: $text)

I don't know if there is better way to do this, and I made an app.

屏幕录制2020-07-20 下午7 38 05 2020-07-20 19_40_13

@eneko
Copy link
Owner

eneko commented Apr 22, 2022

I cannot believe I didn't see this comment until today. Supper happy to see what you made. Did you ever release the app to the App Store?

@L1cardo
Copy link
Author

L1cardo commented Apr 22, 2022

It is really tricky in SwiftUI to make a view into image. This is the project shown on the gif, this is a self-use-only project, codes are very rough.
https://github.com/L1cardo/AppShot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants