فهرست منبع

【VisionPro适配】适配VisionOS

xcbosa mbp16 1 سال پیش
والد
کامیت
db2e1c8529
4فایلهای تغییر یافته به همراه19 افزوده شده و 1 حذف شده
  1. 1 1
      YYWebImage.podspec
  2. 4 0
      YYWebImage/YYImageCache.m
  3. 2 0
      YYWebImage/YYWebImageManager.m
  4. 12 0
      YYWebImage/YYWebImageOperation.m

+ 1 - 1
YYWebImage.podspec

@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
   s.source_files = 'YYWebImage/*.{h,m}', 'YYWebImage/Categories/*.{h,m}'
   s.public_header_files = 'YYWebImage/*.{h}', 'YYWebImage/Categories/*.{h}'
   s.private_header_files = 'YYWebImage/Categories/_*.{h}'
-  s.frameworks = 'UIKit', 'CoreFoundation', 'QuartzCore', 'AssetsLibrary', 'ImageIO', 'Accelerate', 'MobileCoreServices'
+  s.frameworks = 'UIKit', 'CoreFoundation', 'QuartzCore', 'ImageIO', 'Accelerate', 'MobileCoreServices'
   
   s.dependency 'YYImage'
   s.dependency 'YYCache'

+ 4 - 0
YYWebImage/YYImageCache.m

@@ -60,7 +60,11 @@ static inline dispatch_queue_t YYImageCacheDecodeQueue() {
     if (scaleData) {
         scale = ((NSNumber *)[NSKeyedUnarchiver unarchiveObjectWithData:scaleData]).doubleValue;
     }
+#if TARGET_OS_VISION
+    if (scale <= 0) scale = 1.f;
+#else
     if (scale <= 0) scale = [UIScreen mainScreen].scale;
+#endif
     UIImage *image;
     if (_allowAnimatedImage) {
         image = [[YYImage alloc] initWithData:data scale:scale];

+ 2 - 0
YYWebImage/YYWebImageManager.m

@@ -139,9 +139,11 @@ static UIApplication *_YYSharedApplication() {
     if (!app) return;
     
     NSNumber *visiable = timer.userInfo;
+#if !TARGET_OS_VISION
     if (app.networkActivityIndicatorVisible != visiable.boolValue) {
         [app setNetworkActivityIndicatorVisible:visiable.boolValue];
     }
+#endif
     [timer invalidate];
 }
 

+ 12 - 0
YYWebImage/YYWebImageOperation.m

@@ -544,7 +544,11 @@ static void URLInBlackListAdd(NSURL *url) {
         if (now - _lastProgressiveDecodeTimestamp < min) return;
         
         if (!_progressiveDecoder) {
+#if TARGET_OS_VISION
+            _progressiveDecoder = [[YYImageDecoder alloc] initWithScale:1.f];
+#else
             _progressiveDecoder = [[YYImageDecoder alloc] initWithScale:[UIScreen mainScreen].scale];
+#endif
         }
         [_progressiveDecoder updateData:_data final:NO];
         if ([self isCancelled]) return;
@@ -656,13 +660,21 @@ static void URLInBlackListAdd(NSURL *url) {
                 UIImage *image;
                 BOOL hasAnimation = NO;
                 if (allowAnimation) {
+#if TARGET_OS_VISION
+                    image = [[YYImage alloc] initWithData:self.data scale:1.f];
+#else
                     image = [[YYImage alloc] initWithData:self.data scale:[UIScreen mainScreen].scale];
+#endif
                     if (shouldDecode) image = [image yy_imageByDecoded];
                     if ([((YYImage *)image) animatedImageFrameCount] > 1) {
                         hasAnimation = YES;
                     }
                 } else {
+#if TARGET_OS_VISION
+                    YYImageDecoder *decoder = [YYImageDecoder decoderWithData:self.data scale:1.f];
+#else
                     YYImageDecoder *decoder = [YYImageDecoder decoderWithData:self.data scale:[UIScreen mainScreen].scale];
+#endif
                     image = [decoder frameAtIndex:0 decodeForDisplay:shouldDecode].image;
                 }