swift - sd_setImage 显示蓝色图像
问题描述
我正在使用 SDWebImage 设置单元格按钮图像:
cell.categoryButton.sd_setImage(with: URL(string:cell.image), for: .normal, placeholderImage: UIImage(named: "image"))
解决方案
您需要使用该sd_setBackgroundImage
属性,因为您正在设置按钮 ( UIButton
) 的背景图像,而不是将图像设置为UIImageView
.
cell.categoryButton.sd_setBackgroundImage(with: URL(string:cell.image), for: .normal, completed: nil)
推荐阅读
- java - 缺少哪个代码,可点击的菜单项不起作用
- javascript - Javascript,在 React 应用程序中分配给函数组件中的 {},代码审查
- java - Spring Boot WAR 部署
- jquery - 没有 .fadeIn() 和 .fadeOut() 的淡化 div
- offline - 无法在离线模式下使用 gatsby 网站
- ruby - 有没有办法重新定义块内的方法?
- python-2.7 - 如何在使用 for 语句创建联合路径之前检查是否存在联合路径
- xamarin - 错误“确保 kernel-qemu 与系统映像位于同一位置”
- laravel - Laravel 中的会话类
- python - 如何使用 kivy 时钟更改按钮的颜色?