How can I add a border frame in the camera?

人走茶凉 提交于 2019-12-12 17:30:09

问题


I need to add a square frame in the middle of the viewfinder of the react native camera view. There is not information about it in the repository also. And questions there is not being answered also.


回答1:


Which module you are using? react-native-camera or react-native-camera-kit?

If you using react-native-camera just put View (or Image) inside Camera component, then add styles to vertically and horizontally align this view.

Like this:

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>;
     }
}


来源:https://stackoverflow.com/questions/45518740/how-can-i-add-a-border-frame-in-the-camera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!