Update the Example to showing the capability to load PDF/SVG on tvOS/macOS/watchOS as well
This commit is contained in:
parent
e46e21ba41
commit
0cde522360
|
@ -36,6 +36,20 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
|
||||
// Dynamic check to support vector format for both WebImage/AnimatedImage
|
||||
SDWebImageManager.shared.optionsProcessor = SDWebImageOptionsProcessor { url, options, context in
|
||||
var options = options
|
||||
var context = context
|
||||
if let _ = context?[.animatedImageClass] as? SDAnimatedImage.Type {
|
||||
// AnimatedImage supports vector rendering, should not force decode
|
||||
options.insert(.avoidDecodeImage)
|
||||
} else {
|
||||
// WebImage supports bitmap rendering only
|
||||
context?[.svgPrefersBitmap] = true
|
||||
context?[.pdfPrefersBitmap] = true
|
||||
}
|
||||
return SDWebImageOptionsResult(options: options, context: context)
|
||||
}
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
|
|
|
@ -33,6 +33,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
|
||||
// Dynamic check to support vector format for both WebImage/AnimatedImage
|
||||
SDWebImageManager.shared.optionsProcessor = SDWebImageOptionsProcessor { url, options, context in
|
||||
var options = options
|
||||
var context = context
|
||||
if let _ = context?[.animatedImageClass] as? SDAnimatedImage.Type {
|
||||
// AnimatedImage supports vector rendering, should not force decode
|
||||
options.insert(.avoidDecodeImage)
|
||||
} else {
|
||||
// WebImage supports bitmap rendering only
|
||||
context?[.svgPrefersBitmap] = true
|
||||
context?[.pdfPrefersBitmap] = true
|
||||
}
|
||||
return SDWebImageOptionsResult(options: options, context: context)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -20,6 +20,14 @@ class ExtensionDelegate: NSObject, WKExtensionDelegate {
|
|||
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
|
||||
// Dynamic check to support vector format for WebImage
|
||||
SDWebImageManager.shared.optionsProcessor = SDWebImageOptionsProcessor { url, options, context in
|
||||
var context = context
|
||||
// WebImage supports bitmap rendering only
|
||||
context?[.svgPrefersBitmap] = true
|
||||
context?[.pdfPrefersBitmap] = true
|
||||
return SDWebImageOptionsResult(options: options, context: context)
|
||||
}
|
||||
}
|
||||
|
||||
func applicationDidBecomeActive() {
|
||||
|
|
|
@ -23,11 +23,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
|
||||
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
|
||||
// Dynamic check to support both WebImage/AnimatedImage
|
||||
// Dynamic check to support vector format for both WebImage/AnimatedImage
|
||||
SDWebImageManager.shared.optionsProcessor = SDWebImageOptionsProcessor { url, options, context in
|
||||
var options = options
|
||||
var context = context
|
||||
if let _ = context?[.animatedImageClass] as? SDAnimatedImage.Type {
|
||||
// AnimatedImage supports vector rendering
|
||||
// AnimatedImage supports vector rendering, should not force decode
|
||||
options.insert(.avoidDecodeImage)
|
||||
} else {
|
||||
// WebImage supports bitmap rendering only
|
||||
context?[.svgPrefersBitmap] = true
|
||||
|
|
Loading…
Reference in New Issue