Kingfisher简单使用
Kingfisher简单使用
========================
UIKit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| 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 cache.memoryStorage.config.totalCostLimit = 100 * 1024 * 1024 cache.memoryStorage.config.expiration = StorageExpiration.seconds(300) cache.diskStorage.config.sizeLimit = 100 * 1024 * 1024 cache.diskStorage.config.expiration = StorageExpiration.days(7)
|
SwiftUI
1 2 3 4 5 6
| KFImage(URL(string: Images.help.url)) .diskCacheExpiration(.days(365)) .resizable() .aspectRatio(contentMode: .fit) .foregroundColor(.white) .frame(width: 20.fitCGWidth, height: 20.fitCGWidth, alignment: .center)
|