takeSnapshot(with:completionHandler:)
Generates a platform-native image from the web view’s contents asynchronously.
Declaration
func takeSnapshot(with snapshotConfiguration: WKSnapshotConfiguration?, completionHandler: @escaping @MainActor @Sendable (UIImage?, (any Error)?) -> Void)func takeSnapshot(configuration snapshotConfiguration: WKSnapshotConfiguration?) async throws -> UIImagefunc takeSnapshot(with snapshotConfiguration: WKSnapshotConfiguration?, completionHandler: @escaping @MainActor @Sendable (NSImage?, (any Error)?) -> Void)func takeSnapshot(configuration snapshotConfiguration: WKSnapshotConfiguration?) async throws -> NSImageParameters
- snapshotConfiguration:
The object that specifies the portion of the web view to capture, and other capture-related behaviors.
- completionHandler:
The completion handler to call when the image is ready. This block has no return value and takes the following parameters:
- snapshotImage
A platform-native image that contains the specified portion of the web view.
- error
An error object if a problem occurred, or
nilon success.