0

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

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;
    });
});

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

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

4

0 回答 0