Show activity indicator in SDWebImage

前端 未结 18 1424
独厮守ぢ
独厮守ぢ 2021-01-30 09:20

I\'m using SDWebView image and i want to show an Activity Indicator as placeholder, while fetching the image from remote.

I tried Malek\'s answer here How to show an act

18条回答
  •  佛祖请我去吃肉
    2021-01-30 09:40

    SDWebImage has a built in Acitvity Indicator that works perfectly. Try this:

    Updates: SWIFT 5 SDWebImage 5.x.x

            imgView.sd_imageIndicator = SDWebImageActivityIndicator.gray
            imgView.sd_setImage(with: url, placeholderImage: UIImage(named: "placeholder"))
    

    Swift 3:

    imgView.setShowActivityIndicator(true)
    imgView.setIndicatorStyle(.gray)
    imgView.sd_setImage(with: URL(string: urlString), placeholderImage: UIImage(named: "placeholder"))
    

提交回复
热议问题