DylanVann / react-native-fast-image

🚩 FastImage, performant React Native image component.
MIT License
8.09k stars 1.47k forks source link

Gif in ios #1014

Open Dhvani-Impero opened 8 months ago

Dhvani-Impero commented 8 months ago

I have done following to display gif image ` <FastImage // source={APP_IMAGES.ic_runner_gif} source={require('../../assets/images/ic_runner_1.gif')} style={[style.iRunner2,{marginRight : 0}]} resizeMode={FastImage.resizeMode.contain}

          /> 

` But in ios gif only display at once and then stop, how to display gif continuosly in ios

ramen2020 commented 5 months ago

Due to lack of maintenance of SDWebImage, the problem seems to occur with the latest iOS 17. You need to update the internal implementation of fast-image for iOS using patch-package.

I believe it will work if you create a react-native-fast-image+8.6.3.patch file, write the following in it, and then update fast-image using patch-package!


react-native-fast-image+8.6.3.patch

diff --git a/node_modules/react-native-fast-image/RNFastImage.podspec b/node_modules/react-native-fast-image/RNFastImage.podspec
index db0fada..eb884de 100644
--- a/node_modules/react-native-fast-image/RNFastImage.podspec
+++ b/node_modules/react-native-fast-image/RNFastImage.podspec
@@ -16,6 +16,6 @@ Pod::Spec.new do |s|
   s.source_files  = "ios/**/*.{h,m}"

   s.dependency 'React-Core'
-  s.dependency 'SDWebImage', '~> 5.11.1'
-  s.dependency 'SDWebImageWebPCoder', '~> 0.8.4'
+  s.dependency 'SDWebImage', '~> 5.18.5'
+  s.dependency 'SDWebImageWebPCoder', '~> 0.14.1'
 end
diff --git a/node_modules/react-native-fast-image/ios/FastImage/FFFastImageView.m b/node_modules/react-native-fast-image/ios/FastImage/FFFastImageView.m
index f710081..e3ef94a 100644
--- a/node_modules/react-native-fast-image/ios/FastImage/FFFastImageView.m
+++ b/node_modules/react-native-fast-image/ios/FastImage/FFFastImageView.m
@@ -73,12 +73,17 @@ - (void) setImageColor: (UIColor*)imageColor {

 - (UIImage*) makeImage: (UIImage*)image withTint: (UIColor*)color {
     UIImage* newImage = [image imageWithRenderingMode: UIImageRenderingModeAlwaysTemplate];
-    UIGraphicsBeginImageContextWithOptions(image.size, NO, newImage.scale);
-    [color set];
-    [newImage drawInRect: CGRectMake(0, 0, image.size.width, newImage.size.height)];
-    newImage = UIGraphicsGetImageFromCurrentImageContext();
-    UIGraphicsEndImageContext();
-    return newImage;
+
+    UIGraphicsImageRendererFormat *format = [UIGraphicsImageRendererFormat defaultFormat];
+    UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:image.size format:format];
+
+    UIImage *resultImage = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {
+        CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
+        [color set];
+        [newImage drawInRect:rect];
+    }];
+
+    return resultImage;
 }

 - (void) setImage: (UIImage*)image {