From 75380aa3296210777dc0be70a722701767276117 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 13 May 2019 07:31:21 -0700 Subject: [PATCH] Fixes renderingMode not applied to GIF images (#24794) Summary: Bugs like https://github.com/facebook/react-native/issues/24789, we don't apply tintColor to GIF. We fixes it by setting a poster image before add animation. cc. cpojer . [iOS] [Fixed] - Fixes renderingMode not applied to GIF images Pull Request resolved: https://github.com/facebook/react-native/pull/24794 Differential Revision: D15316913 Pulled By: cpojer fbshipit-source-id: 611a07ec17afc962d1eb6b8fc193f118fa623e73 --- Libraries/Image/RCTImageView.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Libraries/Image/RCTImageView.m b/Libraries/Image/RCTImageView.m index 0e5e913317cf2f..e2f221ba85a998 100644 --- a/Libraries/Image/RCTImageView.m +++ b/Libraries/Image/RCTImageView.m @@ -363,10 +363,16 @@ - (void)imageLoaderLoadedImage:(UIImage *)loadedImage error:(NSError *)error for self->_pendingImageSource = nil; } + [self->_imageView.layer removeAnimationForKey:@"contents"]; if (image.reactKeyframeAnimation) { + CGImageRef posterImageRef = (__bridge CGImageRef)[image.reactKeyframeAnimation.values firstObject]; + if (!posterImageRef) { + return; + } + // Apply renderingMode to animated image. + self->_imageView.image = [[UIImage imageWithCGImage:posterImageRef] imageWithRenderingMode:self->_renderingMode]; [self->_imageView.layer addAnimation:image.reactKeyframeAnimation forKey:@"contents"]; } else { - [self->_imageView.layer removeAnimationForKey:@"contents"]; self.image = image; }