如何以编程方式在 react-native 中截取屏幕截图 [英] how to programmatically take a screenshot in react-native
本文介绍了如何以编程方式在 react-native 中截取屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 ReactNative 中截取屏幕截图.我需要一个屏幕截图并将其放在 Image
组件中.我该怎么办?
How can I take a screenshot in ReactNative. I need a screenshot and put it in Image
component. How could I do?
推荐答案
有一个库可以做到这一点:React Native View Shot
There is a library to do just that: React Native View Shot
import RNViewShot from "react-native-view-shot";
RNViewShot.takeSnapshot(viewRef, {
format: "jpeg",
quality: 0.8
})
.then(
uri => console.log("Image saved to", uri),
error => console.error("Oops, snapshot failed", error)
);
这篇关于如何以编程方式在 react-native 中截取屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文