swiftplaceholderblurkingfisher

Placeholder image as Thumbnail(blurred) until actual image loads


I have below code for showing full screen image once User selects it.

fullImage.kf.setImage(with: url)

During the time the actual image downloads, I wanted to show a place holder as the same image but thumbnail size stretched out. This thumbnail was cached by Kingfisher library while showing thumbnails previously.

When I show the image with out KF library, by using regular iOS UIImage downloader it shows a blurred preview of thumbnail stretched and then it shows actual image. How can this be achieved with KF library?


Solution

  • you can use Place holder image like below

    fullImage.kf.setImage(with: url, placeholder: UIImage(named: "placeholder"), options: nil, progressBlock: nil, completionHandler: nil)
    

    But to show thumbnail you must have thumbnail image downloaded separately.