【问题标题】:How to set indicatorType during setBackgroundImage for UIButton using Kingfisher如何使用 Kingfisher 在 UIButton 的 setBackgroundImage 期间设置 indicatorType
【发布时间】:2018-06-06 06:49:01
【问题描述】:

在 Kingfisher 文档中,有关于在为常规 imageView 设置图像时设置 indicatorType 的信息:

    imageView.kf.indicatorType = .activity
    imageView.kf.setImage(with: url)

但是为UIButton设置背景图片时如何设置indicatorType呢?

    myButton.kf.setBackgroundImage(with: url, for: .normal)

【问题讨论】:

    标签: ios swift kingfisher


    【解决方案1】:

    没有直接的方法

    但您可以这样做,创建带有指示器的自定义 UIButton 像这样

    Display activity indicator inside UIButton

    然后这样使用

    let btn = LoadingButton()
        btn.showLoading()
        btn.kf.setBackgroundImage(with: URL(string: ""), for: .normal) { (image, error, cachType, url) in
          btn.hideLoading()
        }
    

    【讨论】:

      猜你喜欢
      • 2013-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多