How to stop gif react-native after 1 time?

后端 未结 1 1271
眼角桃花
眼角桃花 2021-01-23 12:23

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

Any id

1条回答
  •  醉梦人生
    2021-01-23 12:40

    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
    

    And for android

    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'

    0 讨论(0)
提交回复
热议问题