---
title: "pngData(actions:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uigraphicsimagerenderer/pngdata(actions:)"
---

# pngData(actions:)

Creates a PNG-encoded image from a set of drawing instructions.

## Declaration

```swift
func pngData(actions: (UIGraphicsImageRendererContext) -> Void) -> Data
```

## Parameters

- `actions`: A doc://com.apple.uikit/documentation/UIKit/UIGraphicsImageRenderer/DrawingActions block that, when invoked by the renderer, executes a set of drawing instructions to create the output image.

## Return Value

Return Value A Data object representing a PNG-encoded representation of the image created by the supplied drawing actions.

## Discussion

Discussion You provide a set of drawing instructions as the block argument to this method, and the method returns the resulting image as a PNG-encoded Data object. You can call this method repeatedly to create multiple images, each of which has identical dimensions and format.

## See Also

### Creating images

- [image(actions:)](uikit/uigraphicsimagerenderer/image(actions:).md)
- [jpegData(withCompressionQuality:actions:)](uikit/uigraphicsimagerenderer/jpegdata(withcompressionquality:actions:).md)
- [UIGraphicsImageRenderer.DrawingActions](uikit/uigraphicsimagerenderer/drawingactions.md)
