在UIScrollView中缩放核心图形

问题描述:

我想知道哪种方法是在UIScrollView中使用UIView子类放大时缩放Core Graphics绘图的最佳方法。

I was wondering which would be the best way to scale my Core Graphics drawings as I zoomed in using a UIView subclass within a UIScrollView.

当前,当我放大时,绘图变得有些模糊-我知道这是正确的功能,我只想知道开发人员如何覆盖它以保持图像清晰...

Currently when I zoom in, the drawing becomes slightly fuzzy - I know this is correct functioning, I just want to know how developers override it to keep the image sharp...

谢谢!

(我听说过有关使用Core Animation的提示,但我不知道从那个可怕的名字的庞大库开始,哈哈!)

(P.s. I have heard about using Core Animation, but I don't know where to start on that huge library with scary names haha!)

最简单的方法是使用超级采样。基本上,以比显示的分辨率更大的分辨率创建图像,然后将其缩小以显示(UIImageView会为您缩放)。然后,当您放大时,它将简单地放大到原始分辨率。

The simplest way is to use supersampling. Basically, create your image at a larger resolution than it's displayed at, and scale it down for display (UIImageView will scale it for you). Then when you zoom in, it will simply be scaling back up to the original resolution.

这种方法的缺点是您不能将图像放大得太大或它将占用太多内存。

The downside to this approach is you can't scale your image up too large or it will take up too much memory.