Contents

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 -> UIImage
func takeSnapshot(with snapshotConfiguration: WKSnapshotConfiguration?, completionHandler: @escaping @MainActor @Sendable (NSImage?, (any Error)?) -> Void)
func takeSnapshot(configuration snapshotConfiguration: WKSnapshotConfiguration?) async throws -> NSImage

Parameters

  • 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 nil on success.

See Also

Capturing the web view’s content