【发布时间】:2020-09-21 13:02:42
【问题描述】:
我正在构建一个 react-native 应用程序,到目前为止,屏幕将图像从 uri 加载到 BackgroundImage 中,并且图像顶部还加载了一些文本,请参阅附图:
所以我想要的是将这个图像和文本下载到设备上,如果你愿意的话,合并它们?
欢迎任何建议..
谢谢
【问题讨论】:
标签: image react-native download blob react-native-android
我正在构建一个 react-native 应用程序,到目前为止,屏幕将图像从 uri 加载到 BackgroundImage 中,并且图像顶部还加载了一些文本,请参阅附图:
所以我想要的是将这个图像和文本下载到设备上,如果你愿意的话,合并它们?
欢迎任何建议..
谢谢
【问题讨论】:
标签: image react-native download blob react-native-android
我建议您使用来自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>
);
}
}
希望你能理解:)
【讨论】: