An instance of the
UIViewPrintFormatter class lays out the drawn content of a view for printing. The view’s content can span multiple pages.
Instances of three system classes offer usable view print formatters to applications:
UITextView of the UIKit framework, and
MKMapView of the Map Kit framework. To obtain a view print formatter for a print job, call the
viewPrintFormatter and initialize the print formatter’s inherited layout properties.
Add the print formatter to the print job in one of two ways:
If a single print formatter is being used for the print job (with no additional drawing), assign it to the
printFormatterproperty of the
UIPrintInteractionControllershared instance. The inherited
startPageproperty identifies the beginning page of content with which the formatter is associated.
If you are using multiple formatters along with a page renderer, associate each print formatter with a starting page of the printed content. You often take this approach when you want to add content such as headers and footers to what the formatters provide. You have two ways of associating a print formatter with a
You can add print formatters to the
printFormattersproperty of the
startPageproperty of the print formatter specifies the starting page
You can add print formatters by calling
addPrintFormatter:startingAtPageAtIndex:for each print formatter; the second parameter of this method specifies the starting page (and overrides any
View print formatters typically implement the the
drawRect:forViewPrintFormatter: to draw content in a way that is suitable for printing, If they don’t implement this method, their
drawRect: method is called instead.
UIViewPrintFormatter to print the contents of a view is not recommended. To print the contents of a custom view, you should instead draw the view’s contents for printing using a custom
The view from which the view print formatter was derived. (read-only)
Available in iOS 4.2 and later.