如何将模糊应用于图像,然后使用Kingfisher进行缓存?

时间:2017-04-18 22:08:47

标签: swift kingfisher

我正在尝试从URL下载图像,模糊图像,对其进行缓存,然后将其显示在表格视图单元格中。

我这样做了:

let resource = ImageResource(downloadURL: url, cacheKey: recipe.uid)
backgroundImageView.kf.setImage(with: resource)
backgroundImageView.image = backgroundImageView.image?.kf.blurred(withRadius: CGFloat(7.6))

但这意味着我将图像设置为不想要的图像视图后会模糊图像。 有什么建议?谢谢!

1 个答案:

答案 0 :(得分:2)

找到解决方案:

let resource = ImageResource(downloadURL: url, cacheKey: recipe.uid)
let processor = BlurImageProcessor(blurRadius: 4)
backgroundImageView.kf.setImage(with: resource, placeholder: nil, options: [.processor(processor)], progressBlock: nil, completionHandler: nil)