首页 > 解决方案 > 如何在不快速下载的情况下从图像 url 获取图像大小

问题描述

我需要来自 URL 的图像大小,当我在 UITableView 单元格中从 URL 设置图像时,我需要一个 UIImage 框架,以便我可以相应地设置 UIImageView 框架大小。我正在使用下面的代码

cell.imgPostedImage.sd_setImage(with: URL(string: imageArray[0]),placeholderImage: UIImage(named: "placeholder"),options: 
SDWebImageOptions(rawValue: 0), completed: { (image, error, cacheType,imageURL) in
print(image?.size.height)                                        
cell.imgPostedImage.setNeedsLayout()
})

标签: sdwebimageswift3.2

解决方案


推荐阅读