ConsoleUI
ConsoleUI copied to clipboard
Discussion
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.

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?
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