0

I am trying to draw zoomable graphics onto the screen. I currently have a UIView inside of a ScrollView and I'm wondering what the best way is to go about handling/implementing zooming of the graphics I've drawn on the screen.

Gavin Schulz
  • 4,548
  • 4
  • 23
  • 32

1 Answers1

2

You'll probably want to use something along the lines of what I describe in my answer here.

During the pinch-zooming event, a transform will be applied to your UIView, which will zoom the content but will lead to blurring. Once the zooming event is finished, use the -scrollViewDidEndZooming:withView:atScale: delegate method to determine the new scale factor and resize and re-render your UIView appropriately. If you're doing your drawing using Core Graphics within the -drawRect: method of your UIView, this should be pretty easy to manage.

Community
  • 1
  • 1
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • would you have any thoughts on how something like Star Walk is accomplished? Performance is great. Lines expand without blurring or sharpening. Content size must expand somehow. There's momentum, and it's all razor sharp. Could it be UIKit? Perhaps a combo of UIScrollView and Metal? – Max MacLeod Aug 08 '15 at 10:07
  • 1
    @MaxMacLeod - OpenGL. It's what is commonly used for this, and I believe they've stated that's how they render things. Metal didn't exist when they first put this application out. I've done something similar as a proof-of-concept using OpenGL. – Brad Larson Aug 08 '15 at 13:48