有没有一种方法可以让我用 React Native 下载带有附加文本的图像

Is there a way i can download an image with text appended on it with react native

我正在构建一个 react-native 应用程序,到目前为止,屏幕将图像从 uri 加载到 BackgroundImage 中,并且在图像顶部还加载了一些文本,请参阅附图:

所以我想要的是将此图像和文本下载到设备上,如果您愿意,可以合并它们吗?

欢迎提出任何建议..

谢谢

我建议您使用 here 中的 ViewShot 组件。

这是一个如何将它与您的项目集成的示例(请记住,这使用了 ES6 箭头函数语法):

class CaptureImage extends Component {
  capturePic = () => {
    this.refs.viewShot.capture().then(uri => {
      console.log("Path to the image: ", uri);  // do what you want with the url
    })
  };

  render() {
    return (
      <View
        <ViewShot ref="viewShot">

          // your background image components go here (the image with the text you want to capture)

        </ViewShot>

        // rest of your code goes here

        <Button onClick= {() => capturePic()} />  // button just for demonstration purpose
      </View>
    );
  }
}

希望你明白:)