1次后如何停止gif响应本机? [英] How to stop gif react-native after 1 time?

查看:116
本文介绍了1次后如何停止gif响应本机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在响应中有一个gif,我想停止循环 我在视图中添加了图像,并给了图像gif的路径,并且可以正常工作,但是gif陷入了无限循环

I have a gif in react and i want to stop the loop I add an image in my view i give to the image the path of my gif and it's work but the gif go in infinite loop

有停止的想法吗?

<Image
    source={require('./img/anim.gif')}
 />

谢谢

推荐答案

编辑 react-native/Libraries/Image/RCTGIFImageDecoder.m

Edit react-native/Libraries/Image/RCTGIFImageDecoder.m

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
    ...
animation.repeatCount = loopCount == 0 ? 0 : loopCount; // <-- fix for single play gif from joshbedo
animation.fillMode = @"forwards"; // <-- insert this line to prevent the image disappearing after animation

对于Android

更新到最新的壁画版本(androidmanifest.xml)

update to the latest fresco version (androidmanifest.xml)

compile 'com.facebook.fresco:animated-base-support:1.1.0' compile 'com.facebook.fresco:animated-gif:1.1.0'
 compile 'com.facebook.fresco:animated-webp:1.1.0' 
compile 'com.facebook.fresco:webpsupport:1.1.0'

compile 'com.facebook.fresco:animated-base-support:1.1.0' compile 'com.facebook.fresco:animated-gif:1.1.0'
 compile 'com.facebook.fresco:animated-webp:1.1.0' 
compile 'com.facebook.fresco:webpsupport:1.1.0'

这篇关于1次后如何停止gif响应本机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆