Changed RCTImageLoader to always return a UIImage

Summary:
GIF images are currently loaded as a CAKeyframeAnimation, however returning this animation directly from RCTImageLoader was dangerous, as any code that expected a UIImage would crash.

This diff changes RCTGIFImageLoader to return a UIImage of the first frame, with the keyframe animation attached as an associated object. This way, code that is not expecting an animation will still work correctly.
This commit is contained in:
Nick Lockwood
2015-09-04 04:35:44 -07:00
parent 3c4adeb2e7
commit e4110456ab
6 changed files with 110 additions and 50 deletions

View File

@@ -325,6 +325,18 @@ exports.examples = [
);
},
},
{
title: 'Animated GIF',
render: function() {
return (
<Image
style={styles.gif}
source={{uri: 'http://38.media.tumblr.com/9e9bd08c6e2d10561dd1fb4197df4c4e/tumblr_mfqekpMktw1rn90umo1_500.gif'}}
/>
);
},
platform: 'ios',
},
{
title: 'Cap Insets',
description:
@@ -384,5 +396,9 @@ var styles = StyleSheet.create({
},
horizontal: {
flexDirection: 'row',
}
},
gif: {
flex: 1,
height: 200,
},
});