From 0e715eafd469da576b00cf4822a0fe5a092de04f Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Fri, 10 May 2019 16:31:18 +0800 Subject: [PATCH] [iOS] Fixes renderingMode not applied to GIF images --- 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; }