<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIView/draw(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIView(im)drawRect:forViewPrintFormatter:"
  },
  "title" : "draw(_:for:)"
}
-->

# draw(_:for:)

Implemented to draw the view’s content for printing.

```
func draw(_ rect: CGRect, for formatter: UIViewPrintFormatter)
```

## Parameters

`rect`

A rectangle that defines the area for drawing printable content.

`formatter`

An instance of [`UIViewPrintFormatter`](/documentation/UIKit/UIViewPrintFormatter) obtained by calling the [`viewPrintFormatter()`](/documentation/UIKit/UIView/viewPrintFormatter()) method.

## Discussion

You implement this method if you want a view’s printed content to appear differently than its displayed content. If you add a view print formatter to a print job but do not implement this method, the view’s [`draw(_:)`](/documentation/UIKit/UIView/draw(_:)) method is called to provide the content for printing.

For more information about how to implement a custom drawing routine for printed content, see [Drawing and Printing Guide for iOS](https://developer.apple.com/library/archive/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010156).

---

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)