Skip to content

自定义图片缓存规则及匹配查找规则 #2242

Closed Answered by onevcat
52kg asked this question in Q&A
Discussion options

You must be logged in to vote

俺一直以为下采样不会修改缓存数据呢,所以想着那种已缓存大图用在较小视图时下采样处理后显示

这是可以做到的,如果你能确保一开始cache和下载到的就是最大的图,那么只需要 cacheOriginalImage 就行了...其他小图的时候,Kingfisher 会智能去找原图,如果有的话,就不会再重新下载了。https://github.com/onevcat/Kingfisher/wiki/Cheat-Sheet#using-downsamplingimageprocessor-for-high-resolution-images

不过你原来的这个要求确实相对棘手...需要涉及的状态比较多,(每次尝试缓存前都需要先加载之前的缓存,去比较图片大小)..要么继承 ImageCache重载相关方法,要么自己额外维护一套“已缓存”的图片尺寸的对应关系...感觉都很棘手。

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@onevcat
Comment options

@52kg
Comment options

@52kg
Comment options

@onevcat
Comment options

Answer selected by 52kg
@52kg
Comment options

@52kg
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants