0

我想展示并允许用户在 iPhone 和 iPad 上缩放大图像,就像照片应用程序的工作方式一样。

我意识到 CATiledLayer 是这个的 goto 类,但它使用的美学不适用于我的应用程序。它一个接一个地渲染图块,而照片应用程序一次渲染整个屏幕(并在缩放期间和之后显示像素化版本,直到应用程序可以赶上)。

我当然可以实现一个在每次缩放后在背景中呈现图像的视图。但是,一旦源图像变大,这将使应用程序崩溃。所以平铺很吸引人,我宁愿在所有平铺都准备好之前不更新屏幕(同时显示较低分辨率的图像)。

有没有人试图实现这样的东西?有任何想法吗?

4

2 回答 2

3

Apple 的 PhotoScroller 和 ScrollViewSuite 示例展示了如何执行此操作以及更多内容。

还有一个 2010 年 WWDC 视频,标题为“使用滚动视图设计应用程序”,它解释了 PhotoScroller。

于 2012-04-18T08:47:40.347 回答
2

I guess you can have two views: one ImageView with a low res image, and on top a custom view with a CaTiledLayer, with transparent background and hidden at the beginning.

So, when zooming (you'll need to apply zoom to both views) and you need extra resolution, just show the catiledlayered view, so it will load tiles while showing the lowres (and pixelated) on not loaded tiles.

于 2012-01-25T09:50:02.013 回答