3

I am trying to download an image from a URL, blur it, cache it and then display it in a table view cell.

I did this:

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

but this means that I would blur the image after setting it to the image view which is not want I want. Any suggestions? Thanks!

Toma Radu-Petrescu
  • 2,152
  • 2
  • 23
  • 57

1 Answers1

7

Found the solution:

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)
Toma Radu-Petrescu
  • 2,152
  • 2
  • 23
  • 57