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