如何以错误的分辨率显示图像预览?

时间:2013-01-18 16:43:05

标签: ios objective-c image preview

我可以像这样显示大图像异步:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

    CGFloat scale = 1.f;
    UIImage *sourceImage = [UIImage imageWithData:imageData];
    CGSize imageSize = (CGSize){self.size.width / scale, self.size.height / scale};

    UIGraphicsBeginImageContext(imageSize);
    [self drawInRect:(CGRect) {.size = imageSize}];
    UIImage *preloadedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    dispatch_async(dispatch_get_main_queue(), ^{
    imageView.image = preloadedImage;
    });
});

但是我应该使用一些占位符或活动指示器,直到图像加载。

有没有办法在图像加载异步之前显示图像的低分辨率预览?

0 个答案:

没有答案