Ios 如何使用翠鸟为UIButton设置setBackgroundImage期间的indicatorType
在翠鸟文档中,有关于为常规imageView设置图像时设置指示类型的信息:Ios 如何使用翠鸟为UIButton设置setBackgroundImage期间的indicatorType,ios,swift,kingfisher,Ios,Swift,Kingfisher,在翠鸟文档中,有关于为常规imageView设置图像时设置指示类型的信息: imageView.kf.indicatorType = .activity imageView.kf.setImage(with: url) 但在为UIButton设置背景图像时,如何设置indicatorType myButton.kf.setBackgroundImage(with: url, for: .normal) 没有直接的方法 但您可以这样做,创建带有指示器的自定义ui按钮 那
imageView.kf.indicatorType = .activity
imageView.kf.setImage(with: url)
但在为UIButton设置背景图像时,如何设置indicatorType
myButton.kf.setBackgroundImage(with: url, for: .normal)
没有直接的方法 但您可以这样做,创建带有指示器的自定义
ui按钮
那样
然后像这样使用
let btn = LoadingButton()
btn.showLoading()
btn.kf.setBackgroundImage(with: URL(string: ""), for: .normal) { (image, error, cachType, url) in
btn.hideLoading()
}