如何将 SDWebImage 转换为 UIImage?
How can I convert an SDWebImage to a UIImage?
我需要将使用 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"))
}
你可以试试这个回调方法
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)
})
我需要将使用 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"))
}
你可以试试这个回调方法
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)
})