使用 SDWebImage 下载图像后如何立即执行操作?

how to do something right after downloading image using SDWebImage?

因此,我想在图像下载并在 ImageView 中设置后立即向用户显示一条消息。我正在使用 SDWebImage。怎么做?

这是我当前的代码

    profilePictureImageView.sd_setImage(with: referenceImage, placeholderImage: UIImage(named: ImageName.defaultProfilePicture))

你可以这样做

profilePictureImageView.sd_setImage(with: referenceImage, placeholderImage: UIImage(named: "cod_logo"), options: [.highPriority]) { (image, error, cashtype, url) in
    if image != nil{
        // Do something Here after load image
    }
    print(error) // Your error is here
}

这是 pod 'SDWebImage' = '4.0.0' 和 XCode == 11.3.1

self.userAvatar.sd_setImage(with: URL(string: __user_avatar), placeholderImage: UIImage(named: "UserDefalutAvatar"), options: .progressiveDownload, progress: { (receivedSize, expectedSize, targetURL) in
       print("The progress value for the downloading is \(receivedSize)")

}) { (downloadedImage, downloadedError, imageCacheType, downloadedURL) in

       if let _downloadedError = downloadedError {
            print("Download image encountered error. \(_downloadedError.localizedDescription)")
            return
       }
       if let _downloadedImage = downloadedImage {
            print("This is downloaded image, you can do it what you want")
       }

}