0
votes

I have a custom UIView (graphView) that draws a complex graphic in the drawRect based on iPad screen size 1024 x 768. I'd like to take this view and shrink it down for use on the iPhone. I'm hoping to use the same drawing code and shrink the view instead of recalculating my graphic or creating a bitmap cache. The view created on the fly with no Interface Builder.
What is the best approach to do the shrinking? Should I put the view inside of a UIScrollView?

Thanks!

1

1 Answers

0
votes

If possible, just change the current transform matrix before drawing, using something like CGContextScaleCTM. That'll scale all your measurements sent into Core Graphics prior to rasterisation.

If that isn't possible for whatever reason, you should consider still drawing at 1024x768 but applying a suitable transform to the UIView using CGAffineTransformMakeScale. That'll draw at the original pixel size then scale down as a raster operation on the output pixels so it'll be less efficient.