Is there any possible way to snapshot a screen with modal sheet on the screen #956
Replies: 6 comments
-
PS this is for SwiftUI project |
Beta Was this translation helpful? Give feedback.
-
I can make a snapshot of a Alert using this code below, propably it'll work to sheets @looneytsci extension Snapshotting where Value: UIViewController, Format == UIImage {
public static func windowedImage(interfaceStyle: UIUserInterfaceStyle = .unspecified,
precision: Float = 0.98,
perceptualPrecision: Float = 1) -> Snapshotting {
return Snapshotting<UIImage, UIImage>.image(
precision: precision,
perceptualPrecision: perceptualPrecision,
scale: nil
).asyncPullback { viewController in
Async<UIImage> { callback in
UIView.setAnimationsEnabled(false)
let window = UIApplication.shared.windows.first!
window.rootViewController = viewController
window.windowScene?.traitOverrides.userInterfaceStyle = interfaceStyle
DispatchQueue.main.async {
let image = UIGraphicsImageRenderer(bounds: window.bounds).image { _ in
window.drawHierarchy(in: window.bounds, afterScreenUpdates: true)
}
callback(image)
UIView.setAnimationsEnabled(true)
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Im facing the same issue. The code above doesn't snapshot a sheet. |
Beta Was this translation helpful? Give feedback.
-
So far, this isn't working for me. I was trying to test this alert:
The test I have is:
|
Beta Was this translation helpful? Give feedback.
-
Is that last line supposed to be:
? |
Beta Was this translation helpful? Give feedback.
-
Any updates on this? |
Beta Was this translation helpful? Give feedback.
-
I'm trying to make a snapshot for a view, which can open bottomSheet via .fullScreenCover and transparent background. Looks like It captures only the view layer without bottomSheet layer. Can I make the snapshot of the full view hierarchy? Or can I implement some custom snapshotting strategy with modal screen capturing?
Beta Was this translation helpful? Give feedback.
All reactions