我将活动类型设置如下。我用它在Google地图上的标记中显示图像
infoView.userImage.kf.indicatorType = .activity
它不会动画,并且在加载图像后也不会消失。如果我单击外部标记,然后单击返回,则发现图像已下载。我什至尝试在图片下载完成后设置为无,但没有结果
ImageCache.default.retrieveImage(forKey: key!, options: [.fromMemoryCacheOrRefresh]) {
image, cacheType in
if let image = image {
//image found in cache so use it to create cell
infoView.userImage.image = image
infoView.userImage.kf.indicatorType = .none
} else {
//image not found in cache so below method retrieves and on successful retrieval, stores in cache
infoView.userImage.kf.setImage(with: url,
placeholder: nil,
options: [.transition(ImageTransition.fade(1))],
progressBlock: { receivedSize, totalSize in },
completionHandler: { image, error, cacheType, imageURL in
if error != nil {
ImageCache.default.store(UIImage(), forKey: key!)
infoView.userImage.kf.indicatorType = .none
} else {
ImageCache.default.store(image!, forKey: key!)
infoView.userImage.kf.indicatorType = .none
}
}
)
} //end of else
} //end of ImageCache.default.retrieveImage
谢谢 灰烬