iOS SD加载gif大图导致内存崩溃的问题

2021-08-20  本文已影响0人  Rex_

SDImage加载超大尺寸的gif图片,可以在xcode里看到内存爆增几百兆,这个问题网上没找到很好的解决方案。
所以我只好勉为其难的强制修改了sd中渲染gif的尺寸来解决,将gif的大小限制为屏幕的宽高。
实际效果看起来还行,就是手机渲染时,cpu会因为计算CGImageRef的绘制而暂时很高。

就是这个样子了
CGSize sizefix = CGSizeMake((thumbnailSize.width == 0 ? [UIScreen mainScreen].bounds.size.width : thumbnailSize.width), (thumbnailSize.height == 0 ? [UIScreen mainScreen].bounds.size.height : thumbnailSize.height));
for (size_t i = 0; i < count; i++) {
    UIImage *image = [self.class createFrameAtIndex:i source:source     scale:scale preserveAspectRatio:preserveAspectRatio   thumbnailSize:sizefix options:nil];
    if (!image) {
        continue;
    }
上一篇 下一篇

猜你喜欢

热点阅读