将快照移到图像文件夹

时间:2018-10-12 07:40:49

标签: react-native snapshot

我正在使用React-native构建适用于iOS的应用程序,并且使用我的代码成功捕获了屏幕截图。问题是我想将快照移到Images文件夹,以便用户可以轻松访问。 我使用以下代码:

    snapshot = async () => {

    const targetPixelCount = 1080; // If you want full HD pictures
    const pixelRatio = PixelRatio.get(); // The pixel ratio of the device
    // pixels * pixelratio = targetPixelCount, so pixels = targetPixelCount / pixelRatio
    const pixels = targetPixelCount / pixelRatio;

    const result = await Expo.takeSnapshotAsync(this, {
      result: 'file',
      height: pixels,
      width: pixels,
      quality: 1,
      format: 'png',
    });

    if (result) {
      //RNFS.moveFile(result, 'Documents/snapshot.png');
      Alert.alert('Snapshot', "Snapshot saved to " + result);
    }
    else {
      Alert.alert('Snapshot', "Failed to save snapshot");
    }
  }

有人知道如何将图像移到图像文件夹吗?

谢谢

1 个答案:

答案 0 :(得分:1)