1.UIImageView
- 1.在桥接文件XX-Bridging-Header.h中引入
#import "SDWebImage/SDWebImage.h"
- 2.代码
imageView?.sd_setImage(with: URL(string: self.testUrlArr[index] as! String), placeholderImage: UIImage(named: "banner"), options: SDWebImageOptions(), context: nil)
2.UIButton
- 1.在桥接文件XX-Bridging-Header.h中引入
#import "SDWebImage/UIButton+WebCache.h"
- 2.代码
headBtn.sd_setBackgroundImage(with: URL(string: model.headImageUrl), for: .normal, completed: nil)
参考博客:
SDWebimage 的 UIButton 背景图片设置方法