I had moderate luck, just strolling through my hierarchy of views and calling -drawRect: me. There, itβs a little configured what you do before each, for example, translating ctm and clearing the text matrix, but when you have done this for each view, you can do this:
UIGraphicsPushContext(ctx); [self drawRect:self.frame]; UIGraphicsPopContext();
The PDF that it creates is based on a vector, not just a flat bitmap, so it scales well and you can select text in the viewer / browser. This only works on the usual vanilla graphic design and very simple things like UILabels. I doubt that this will work with more complex UIKit objects (I think of table views and scrolling). In addition, you will need additional work for UIImageViews (which, I assume, sets the layer content property with CGImageRef), and if you have other attributes and transformations at the layer level, even more work.
I hope Apple provides us with a better solution than maintaining parallel drawing code!
joeybladb
source share