如何在 React Native IOS 中 运行 GIF 一次?
how to run GIF once in react native IOS?
我使用 React Native 为 android 构建了一个项目,我在项目中使用了 gif 图像,并且在 android gif 运行 中设置了一次 gif 循环,它是是的,但在 ios 中是循环如何强制它 运行 一次?
如果您控制 GIF 的创建,最简单的方法是将信息放入 GIF 元数据中,例如使用 gifsicle
:
gifsicle my_gif.gif --no-loopcount > my_gif-noloop.gif
如果不能,您可以按照建议编辑/node_modules/react-native/Libraries/Image/RCTGIFImageDecoder.m
here:
CAKeyframeAnimation *animation = [CAKeyframeAnimation
animationWithKeyPath:@"contents"];
...
animation.repeatCount = loopCount == 0 ? 0 : loopCount; // Avoid infinite loop
animation.fillMode = @"forwards"; // avoid image to desapear after loop
我使用 React Native 为 android 构建了一个项目,我在项目中使用了 gif 图像,并且在 android gif 运行 中设置了一次 gif 循环,它是是的,但在 ios 中是循环如何强制它 运行 一次?
如果您控制 GIF 的创建,最简单的方法是将信息放入 GIF 元数据中,例如使用 gifsicle
:
gifsicle my_gif.gif --no-loopcount > my_gif-noloop.gif
如果不能,您可以按照建议编辑/node_modules/react-native/Libraries/Image/RCTGIFImageDecoder.m
here:
CAKeyframeAnimation *animation = [CAKeyframeAnimation
animationWithKeyPath:@"contents"];
...
animation.repeatCount = loopCount == 0 ? 0 : loopCount; // Avoid infinite loop
animation.fillMode = @"forwards"; // avoid image to desapear after loop