-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Description
let processor = DownsamplingImageProcessor(size: size)
processorIdentifier = processor.identifier
options = [
.processor(processor),
.scaleFactor(UIScreen.main.scale),
.cacheOriginalImage
]
self.kf.setImage(
with: url,
placeholder: placeHolderImg,
options: options, completionHandler:
{
result in
switch result {
case .success(let value):
CalamansiPrint(" Task done for: \(value.source.url?.absoluteString ?? "") cacheType \(value.cacheType) == \(value.image.size) setSize \(size) self.bounds \(self.bounds.size)")
case .failure(let error):
CalamansiPrint("Job failed: \(error.localizedDescription)")
}
})
然后我这样写就没有闪动的效果了
if isShowPlaceHolder {
self.kf.indicatorType = .activity
if !urlStr.hasSuffix(".gif") {
printLog(message: "--=-=-=不是gif")
// let processor = ResizingImageProcessor(referenceSize: size, mode: .aspectFit)
// processorIdentifier = processor.identifier
let processor = DownsamplingImageProcessor(size: size)
processorIdentifier = processor.identifier
options = [
.processor(processor),
.scaleFactor(UIScreen.main.scale),
.transition(.fade(1)),
.cacheOriginalImage,
]
}
} else {
self.kf.indicatorType = .none
if !urlStr.hasSuffix(".gif") {
printLog(message: "--=-=-=不是gif")
// let processor = ResizingImageProcessor(referenceSize: size, mode: .aspectFit)
// processorIdentifier = processor.identifier
let processor = DownsamplingImageProcessor(size: size)
processorIdentifier = processor.identifier
options = [
.processor(processor),
.scaleFactor(UIScreen.main.scale),
// .transition(.fade(1)),
.cacheOriginalImage,
]
}
}
if let cacheKey = url?.cacheKey {
let cacheType = KingfisherManager.shared.cache.imageCachedType(forKey: cacheKey, processorIdentifier: processorIdentifier)
CalamansiPrint("[Image kf] test1: \(cacheType) \(cacheKey) ----\(urlString)")
if cacheType == .memory, !urlStr.hasSuffix(".gif") {
KingfisherManager.shared.cache.retrieveImage(forKey: cacheKey, options: options) {
result in
switch result {
case .success(let value):
self.image = value.image
CalamansiPrint(" Task done for: cacheType \(value.cacheType) == \(value.image?.size) setSize \(size) self.bounds \(self.bounds.size)")
case .failure(let error):
CalamansiPrint("Job failed: \(error.localizedDescription)")
}
}
return
}
}
self.kf.setImage(
with: url,
placeholder: placeHolderImg,
options: options, completionHandler:
{
result in
switch result {
case .success(let value):
CalamansiPrint(" Task done for: \(value.source.url?.absoluteString ?? "") cacheType \(value.cacheType) == \(value.image.size) setSize \(size) self.bounds \(self.bounds.size)")
case .failure(let error):
CalamansiPrint("Job failed: \(error.localizedDescription)")
}
})
Metadata
Metadata
Assignees
Labels
No labels