<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIGraphicsImageRenderer/pngData(actions:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIGraphicsImageRenderer(im)PNGDataWithActions:"
  },
  "title" : "pngData(actions:)"
}
-->

# pngData(actions:)

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

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

## Parameters

`actions`

A [`UIGraphicsImageRenderer.DrawingActions`](/documentation/UIKit/UIGraphicsImageRenderer/DrawingActions) block that, when invoked by the renderer, executes a set of drawing instructions to create the output image.

## Return Value

A <doc://com.apple.documentation/documentation/Foundation/Data> object representing a PNG-encoded representation of the image created by the supplied drawing actions.

## 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 <doc://com.apple.documentation/documentation/Foundation/Data> object.

You can call this method repeatedly to create multiple images, each of which has identical dimensions and format.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)