Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct ContentView: View {
- var textView: some View {
- Text("Hello, SwiftUI")
- .padding()
- .background(.red)
- .foregroundColor(.white)
- .clipShape(Capsule())
- }
- var body: some View {
- VStack {
- textView
- .onTapGesture {
- let renderer = ImageRenderer(content: textView)
- if let uiImage = renderer.uiImage {
- print("created UIImage - size:", uiImage.size)
- if let d = uiImage.jpegData(compressionQuality: 0.9) {
- print("image as jpeg data successful")
- // use the data somehow
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement