问题描述
如何在网页上显示低分辨率图片,然后在第二次延迟后加载高分辨率版本?这是做层吗? Threads?
How do I display a low resolution image on a page and then after a second delay load a high resolution version? Is this done with layers? Threads?
推荐答案
我知道这篇文章是旧的,但是如果有人在寻找它, a href =https://github.com/Nyx0uf/NYXImagesKit =nofollow> NYXImagesKit 执行您所寻找的内容。
I know this post is old, but just in case anyone is looking for it, there is a project called NYXImagesKit that does what you are looking for.
它有一个名为 NYXProgressiveImageView
的类,它是 UIImageView
的子类。
It has a class named NYXProgressiveImageView
that is a subclass of UIImageView
.
所有你需要做的是:
NYXProgressiveImageView * imgv = [[NYXProgressiveImageView alloc] init];
imgv.frame = CGRectMake(0, 0, 320, 480);
[imgv loadImageAtURL:[NSURL URLWithString:@"http://yourimage"]];
[self.view addSubview:imgv];
[imgv release];
此外,一个很好的选择是将图像保存为隔行扫描
,使其加载质量低,并与下载改善。如果图像正常,则从上到下加载。
Also, a good option is to save your images as interlaced
so that it loads with low quality and improve with the download. If the image is normal it is loaded from top to bottom.
这篇关于加载低分辨率图像和高分辨率的渐进负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!