选择图片分享功能

This commit is contained in:
2025-08-17 22:08:25 +08:00
parent e6afca5ba6
commit d80289fe73
19 changed files with 1402 additions and 110 deletions

View File

@@ -0,0 +1,39 @@
import UIKit
///
class ImageCacheManager {
static let shared = ImageCacheManager()
private let cache = NSCache<NSString, UIImage>()
//
private init() {
//
cache.totalCostLimit = 1024 * 1024 * 100 // 100MB
}
///
/// - Parameter url: URL
/// - Returns:
func getImage(for url: String) -> UIImage? {
return cache.object(forKey: url as NSString)
}
///
/// - Parameters:
/// - image:
/// - url: URL
func saveImage(_ image: UIImage, for url: String) {
cache.setObject(image, forKey: url as NSString)
}
/// URL
/// - Parameter url: URL
func removeImage(for url: String) {
cache.removeObject(forKey: url as NSString)
}
///
func clearAllCache() {
cache.removeAllObjects()
}
}