在没有CATiledLayer的iOS上呈现和缩放大图像 [英] Present and zoom large images on iOS without CATiledLayer

查看:162
本文介绍了在没有CATiledLayer的iOS上呈现和缩放大图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想呈现并允许用户在iPhone和iPad上缩放大图像的方式与照片应用程序的工作方式非常相似。

I'd like to present and allow the user to zoom large images on the iPhone and iPad in much the same way that the Photos app works.

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

I realize CATiledLayer is the goto class for this, but the aesthetic it uses won't work for my application. It renders tiles one after another, while the Photos app renders the whole screen at once (and shows a pixellated version during and after a zoom until the app can catch up).

我当然可以实现一个视图,在每次缩放后在后台渲染图像。但是,一旦源图像变大,这将使应用程序崩溃。所以平铺是有吸引力的,我宁愿不更新屏幕,直到所有瓷砖准备就绪(并在此期间显示较低分辨率的图像)。

I could certainly implement a view which renders the image in the background after each zoom. However, once the source image gets to large, this will crash the app. So tiling is appealing, I would just prefer to not update the screen until all tiles are ready (and show a lower-res image in the meantime).

有没有人试过实现这样的事情?任何想法?

Has anyone tried to implement something like this? Any ideas?

推荐答案

我想你可以有两个视图:一个具有低分辨率图像的ImageView,顶部是一个自定义视图使用CaTiledLayer,具有透明背景并在开头隐藏。

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.

因此,当缩放(您需要对两个视图应用缩放)并且您需要额外的分辨率时,只显示catiledlayered视图,所以它将加载tile,同时在未加载的tile上显示lowres(和像素化)。

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.

这篇关于在没有CATiledLayer的iOS上呈现和缩放大图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆