如何将SDWebImage转换为UIImage?

问题描述 投票:0回答:1

我需要将使用SDWebImage从Firebase下载的图像转换为UIImage。我怎样才能做到这一点?到目前为止,这是我的代码:

Database.database().reference().child("movies").child(movieNumString).observeSingleEvent(of: .value, with: { (snapshot) in
    if let dictionary = snapshot.value as? [String: AnyObject] {
        let UrlString: String? = ((dictionary["posterPhotoURL"] as? String))
        let Url = URL(string: (UrlString)!)

        self.moviePosterImageView.sd_setImage(with: Url, placeholderImage: #imageLiteral(resourceName: "PImage"))
}
ios swift uiimage sdwebimage
1个回答
1
投票

你可以试试这个callBack方法

self.moviePosterImageView.sd_setImage(with:Url,
               placeholderImage: #imageLiteral(resourceName: "PImage"), 
               options: [],
               completed: { (image, error,cacheType, url) in
        // here image is the UIImage    

    self.moviePosterImageView.image = image?.roundedWithBorder(width: 2, color: .red)   
})
© www.soinside.com 2019 - 2024. All rights reserved.