我需要将使用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"))
}
答案 0 :(得分: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)
})