0

我想创建一个使用全屏照片的 iOS 应用程序,如果最终用户的连接速度很慢,这可能会给他们带来很多等待时间。我不想向他们显示“加载”图标,而是希望以线性方式(从上到下,Web 浏览器加载图像的方式)或更有趣地以非线性方式显示图像。我的意思是,是否有一种函数/方法可以从图像的任何部分随机加载像素/部分,直到图像完全完成?

4

1 回答 1

2

你应该看看

CGImageSourceCreateIncremental and CGImageSourceUpdateData

这里的方法https://developer.apple.com/library/ios/documentation/graphicsimaging/Reference/CGImageSource/Reference/reference.html

您也可以尝试 NYXImagesKit 库 ( https://github.com/Nyx0uf/NYXImagesKit )

算法描述 - http://cocoaintheshell.com/2011/05/progressive-images-download-imageio/

样本:

NYXProgressiveImageView * imgv = [[NYXProgressiveImageView alloc] init];
imgv.frame = CGRectMake(0, 0, 320, 480);
[imgv loadImageAtURL:[NSURL URLWithString:@"http://yourimage"]];
[self.view addSubview:imgv];
于 2014-02-15T21:31:15.523 回答