Kingfisher简单使用
Kingfisher简单使用
========================
UIKit
let url = dataShare.queryFromManyTable(with: modelName, from: [dataShare.cuturalRelicsIntroduction,
dataShare.models3DIntroduction,
dataShare.paintingModelsIntroduction])?.image
objectImageView.kf.indicatorType = .activity
objectImageView.kf.setImage(with: URL(string: url))
// 设置超时时间
let downloader = KingfisherManager.shared.downloader
// 超时时间(秒)
downloader.downloadTimeout = 50
// 获取缓存代销
let cache = KingfisherManager.shared.cache
// 设置最大缓存为多少 100M 默认是无上限
cache.memoryStorage.config.totalCostLimit = 100 * 1024 * 1024
// 设置保存时间 1天 默认5分钟
cache.memoryStorage.config.expiration = StorageExpiration.seconds(300)
cache.diskStorage.config.sizeLimit = 100 * 1024 * 1024
cache.diskStorage.config.expiration = StorageExpiration.days(7)
SwiftUI
KFImage(URL(string: Images.help.url))
.diskCacheExpiration(.days(365))
.resizable()
.aspectRatio(contentMode: .fit)
.foregroundColor(.white)
.frame(width: 20.fitCGWidth, height: 20.fitCGWidth, alignment: .center)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 张赛东!
评论