I found this way to take screenshot in full screen view of SwiftUI. But How to take screenshot of a ScrollView content view?
Thanks!
Normal way:
SwiftUI Extension
Swift Extension
Thanks!
Normal way:
SwiftUI Extension
Code Block swift extension View { func takeScreenshot(origin: CGPoint, size: CGSize) -> UIImage { let window = UIWindow(frame: CGRect(origin: origin, size: size)) let hosting = UIHostingController(rootView: self) window.rootViewController = hosting window.makeKeyAndVisible() return hosting.view.snapshotImage()! } }
Swift Extension
Code Block swift extension UIView { func snapshotImage() -> UIImage { ..... } }