Created
June 13, 2022 15:39
-
-
Save anupamchugh/19f76681139b8529eb389f7cba1d40ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
@State var exportImage: UIImage? | |
@State var bgColor = Color.blue | |
@State var text = "Hello, World!" | |
var body: some View { | |
VStack{ | |
PosterView(bgColor: $bgColor, text: $text) | |
Form{ | |
Section{ | |
TextField("Enter Title", text: $text) | |
ColorPicker("Choose a background color", selection: $bgColor).padding(.horizontal) | |
} | |
Section{ | |
Button("Export Poster"){ | |
exportImage = ImageRenderer(content: PosterView(bgColor: $bgColor, text: $text)).uiImage | |
} | |
} | |
} | |
HStack{ | |
if let exportImage{ | |
Image(uiImage: exportImage) | |
.scaledToFill() | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment