react-native-camera - 如何在相机中添加边框?

标签 react-native-camera

我需要在 React Native 相机 View 的取景器中间添加一个方框。存储库中也没有关于它的信息。还有问题也没有得到回答。

I need to make the camera view like this

最佳答案

您使用的是哪个模块? react-native-camera 还是 react-native-camera-kit

如果你使用 react-native-camera 只需将 View(或 Image)放在 Camera 组件中,然后将样式添加到垂直和水平对齐此 View 。

像这样:

const styles = {
    container: {
        flex: 1,
    },

    camera: {
        flex: 1,
        // These below are most important, they center your border view in container
        // ref: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
        alignItems: "center",
        justifyContent: "center"
    },

    borderImage: {
        // Your styles for image, or custom borders
    },
}


class Component extends React.Component {

   ...

    render(){
        return <View style={styles.container}>
           <Camera style={styles.camera}>
              <Image style={styles.borderImage} source={require("./img/qrBorder.png")} />
           </Camera>
        </View>;
     }
}

关于react-native-camera - 如何在相机中添加边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45518740/

相关文章:

react-native - react native ios QRCodeScanner 错误(相机未授权)

javascript - 渲染没有返回任何内容。这通常意味着缺少 return 语句

android - 保存一张花了很长时间的照片

javascript - React-native-camera - 类型错误 : undefined is not an object

android - react 相机 : undefined is not an object(evaluatiing 'CameraManager. Aspect.fill)

react-native - react 原生相机条码类型

android - react-native-camera:Android 应用程序崩溃没有错误

android - 使用react-native-camera创建非常简单的应用程序时出错

javascript - 如何一次扫描一个条码? [ react native 相机]