【发布时间】:2021-10-17 08:12:44
【问题描述】:
我有一个UITableViewCell,其中有一个UIImageView,图像占位符工作得很好,但是当使用SDWebImage从带有实际数据的url获取图像时,图像将显示在UIImageView之外。
我尝试过使用以下方法,但没有任何效果。
cell.imageView?.contentMode = .scaleAspectFit
cell.imageView?.clipsToBounds = false
cell.imageView?.layer.masksToBounds = true
我已附上参考图片以进一步了解。
UITableViewCell
我也尝试将图像从服务器调整为 40 x 40,但仍然是同样的问题。
//cell.imageView?.sd_setImage(with: URL(string: "\(Constants.string.WEB)/assets/\(dict.image)"), placeholderImage: UIImage(named: Constants.string.IMAGE_PLACEHOLDER_60))
cell.imageView?.sd_setImage(with: URL(string: "\(Constants.string.WEB)/assets/\(dict.image)")) { (image, error, cache, urls) in
if error != nil {
cell.imageView?.image = UIImage(named: Constants.string.IMAGE_PLACEHOLDER_60)!.resizeImageWith(newSize: CGSize(width: 40, height: 40))
} else {
cell.imageView?.image = image!.resizeImageWith(newSize: CGSize(width: 40, height: 40))
}
}
【问题讨论】:
标签: swift uitableview uiimageview uikit sdwebimage